You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "ConfX (Jira)" <ji...@apache.org> on 2023/09/14 18:37:00 UTC
[jira] [Created] (HADOOP-18904) get local file system fails with a casting error
ConfX created HADOOP-18904:
------------------------------
Summary: get local file system fails with a casting error
Key: HADOOP-18904
URL: https://issues.apache.org/jira/browse/HADOOP-18904
Project: Hadoop Common
Issue Type: Bug
Reporter: ConfX
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 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.
h2. 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:
{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)
...{code}
Or simply set the configuration parameter and call the method using a {{Configuration}} object and the exception would be triggered.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org