{"record":{"id":"7bb99f11acdb4c7c","repo":"apache/druid","slug":"hdfs-reader-not-supported","errorCode":null,"errorMessage":"HDFS Reader not supported","messagePattern":"HDFS Reader not supported","errorType":"exception","errorClass":"UOE","httpStatus":null,"severity":"error","filePath":"extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPuller.java","lineNumber":140,"sourceCode":"\n      @Override\n      public InputStream openInputStream() throws IOException\n      {\n        final FileSystem fs = path.getFileSystem(config);\n        return fs.open(path);\n      }\n\n      @Override\n      public OutputStream openOutputStream() throws IOException\n      {\n        final FileSystem fs = path.getFileSystem(config);\n        return fs.create(path, overwrite);\n      }\n\n      @Override\n      public Reader openReader(boolean ignoreEncodingErrors)\n      {\n        throw new UOE(\"HDFS Reader not supported\");\n      }\n\n      @Override\n      public CharSequence getCharContent(boolean ignoreEncodingErrors)\n      {\n        throw new UOE(\"HDFS CharSequence not supported\");\n      }\n\n      @Override\n      public Writer openWriter()\n      {\n        throw new UOE(\"HDFS Writer not supported\");\n      }\n\n      @Override\n      public long getLastModified()\n      {\n        try {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPuller.java#L122-L158","documentation":"The anonymous FileObject returned by HdfsDataSegmentPuller.buildFileObject only implements stream-based access (openInputStream/openOutputStream); openReader deliberately throws UOE(\"HDFS Reader not supported\") because HDFS segments are binary and the javax.tools.FileObject character-reader contract has no meaningful HDFS implementation. Calling openReader on this FileObject always throws; it is an unconditional unsupported-operation signal, not a data-dependent failure.","triggerScenarios":"Any code path that obtains the FileObject from buildFileObject(uri, config) and invokes openReader(ignoreEncodingErrors) — e.g. tooling that treats deep-storage URIs as text FileObjects, or generic compiler/FileObject consumers.","commonSituations":"Custom tooling or third-party code treating hdfs:// URIs as character sources; frameworks that enumerate FileObject methods for metadata or text inspection of segment descriptors.","solutions":["Use openInputStream() and read the bytes yourself, decoding to text explicitly if the content is character data.","Route text-file reads to a scheme-appropriate puller (e.g. a local or HTTP puller) instead of the HDFS one.","If you control the calling code, branch on URI scheme before choosing a Reader-based API and fall back to InputStream for hdfs://."],"exampleFix":"// before\nReader r = fileObject.openReader(true);\n// after\ntry (InputStream in = fileObject.openInputStream()) {\n  String text = new String(ByteStreams.toByteArray(in), StandardCharsets.UTF_8);\n}","handlingStrategy":"type-guard","validationCode":"if (!uri.getScheme().equalsIgnoreCase(\"hdfs\")) { useNonHdfsReader(uri); }","typeGuard":"boolean supportsReader(FileObject fo) { return !(fo.getClass().getName().startsWith(\"org.apache.druid.storage.hdfs\")); }","tryCatchPattern":"try { return fo.openReader(true); }\ncatch (UOE e) { return readViaInputStream(fo); }","preventionTips":["Never use Reader/CharSequence FileObject APIs against hdfs:// URIs.","Wrap HDFS access in helpers that expose only InputStream-based reads.","Document the HDFS FileObject's supported surface (openInputStream/openOutputStream/getLastModified/delete only)."],"tags":["hdfs","unsupported-operation","fileobject","reader"],"backgroundTag":"unsupported-operation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}