Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-18904

get local file system fails with a casting error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • 3.3.6
    • None
    • fs

    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

      1. Set fs.file.impl=org.apache.hadoop.fs.RawLocalFileSystem
      2. 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

          Activity

            People

              Unassigned Unassigned
              FuzzingTeam ConfX
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: