You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "ConfX (Jira)" <ji...@apache.org> on 2023/07/20 08:50:00 UTC
[jira] [Created] (HBASE-27987) HCommon get local file system fails with a casting error
ConfX created HBASE-27987:
-----------------------------
Summary: HCommon get local file system fails with a casting error
Key: HBASE-27987
URL: https://issues.apache.org/jira/browse/HBASE-27987
Project: HBase
Issue Type: Bug
Reporter: ConfX
Attachments: reproduce.sh
h2. 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}}
h2. Where's the bug
In the function {{getLocal}} of {{FileSystem}} in HCommon:
{code:java}
public static LocalFileSystem getLocal(Configuration conf)
throws IOException {
return (LocalFileSystem)get(LocalFileSystem.NAME, conf);
} {code}
the returned file system is directly casted 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.
h2. How to reproduce
# Set {{fs.file.impl=org.apache.hadoop.fs.RawLocalFileSystem}}
# Run {{org.apache.hadoop.hbase.TestHBaseTestingUtility#testMiniDFSCluster}}
and the following exception should be observed:
{code:java}
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) at org.apache.hadoop.hbase.HBaseTestingUtility.setupDataTestDirOnTestFS(HBaseTestingUtility.java:536) at org.apache.hadoop.hbase.HBaseTestingUtility.getDataTestDirOnTestFS(HBaseTestingUtility.java:510) at org.apache.hadoop.hbase.HBaseTestingUtility.getDataTestDirOnTestFS(HBaseTestingUtility.java:524) at org.apache.hadoop.hbase.HBaseTestingUtility.createDirsAndSetProperties(HBaseTestingUtility.java:737) at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniDFSCluster(HBaseTestingUtility.java:682) at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniDFSCluster(HBaseTestingUtility.java:665) at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniDFSCluster(HBaseTestingUtility.java:653) at org.apache.hadoop.hbase.TestHBaseTestingUtility.testMiniDFSCluster(TestHBaseTestingUtility.java:377) {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)