Details
-
Bug
-
Status: Open
-
Trivial
-
Resolution: Unresolved
-
3.3.6
-
None
Description
What happened
After setting fs.file.impl=org.apache.hadoop.fs.RawLocalFileSystem, trying to acquire local file system using the getLocal in org.apache.hadoop.fs fails with java.lang.ClassCastException
Where's the bug
In the function getLocal of FileSystem in HCommon:
public static LocalFileSystem getLocal(Configuration conf) throws IOException { return (LocalFileSystem)get(LocalFileSystem.NAME, conf); }
the returned file system is directly cast to LocalFileSystem without checking. If the user set the implementation of the local filesystem to be Raw rather than Checksum, this type cast would fail.
How to reproduce
- Set fs.file.impl=org.apache.hadoop.fs.RawLocalFileSystem
- Run the following test in HBase: org.apache.hadoop.hbase.TestHBaseTestingUtility#testMiniDFSCluster
and the following exception should be observed:
java.lang.ClassCastException: class org.apache.hadoop.fs.RawLocalFileSystem cannot be cast to class org.apache.hadoop.fs.LocalFileSystem (org.apache.hadoop.fs.RawLocalFileSystem and org.apache.hadoop.fs.LocalFileSystem are in unnamed module of loader 'app') at org.apache.hadoop.fs.FileSystem.getLocal(FileSystem.java:441) at org.apache.hadoop.hbase.HBaseTestingUtility.getNewDataTestDirOnTestFS(HBaseTestingUtility.java:550) ...
Or simply set the configuration parameter and call the method using a Configuration object and the exception would be triggered.
Attachments
Issue Links
- links to