{"record":{"id":"e35e62a52cd7a0d1","repo":"apache/druid","slug":"hdfs-charsequence-not-supported","errorCode":null,"errorMessage":"HDFS CharSequence not supported","messagePattern":"HDFS CharSequence 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":146,"sourceCode":"      }\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 {\n          final FileSystem fs = path.getFileSystem(config);\n          return fs.getFileStatus(path).getModificationTime();\n        }\n        catch (IOException ex) {\n          throw new HdfsIOException(ex);\n        }","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPuller.java#L128-L164","documentation":"Same pattern as openReader: the HDFS FileObject's getCharContent(ignoreEncodingErrors) throws UOE(\"HDFS CharSequence not supported\") because returning the whole file content as a CharSequence is not implemented for HDFS-backed binary segment files. The method exists only to satisfy the javax.tools.FileObject interface and is intentionally unimplemented for this storage backend.","triggerScenarios":"Calling getCharContent on the FileObject produced by HdfsDataSegmentPuller.buildFileObject — any consumer expecting in-memory character content of an hdfs:// URI.","commonSituations":"Generic FileObject-based tooling that buffers file content as CharSequence; code ported from local-filesystem FileObjects to HDFS URIs without changing the content-access API.","solutions":["Read via openInputStream() and materialize the CharSequence yourself from the bytes.","Use a different URIDataPuller/FileObject implementation for character-content access.","Guard call sites: for hdfs:// scheme URIs, never call getCharContent."],"exampleFix":"// before\nCharSequence cs = fileObject.getCharContent(false);\n// after\ntry (InputStream in = fileObject.openInputStream()) {\n  CharSequence cs = new String(ByteStreams.toByteArray(in), StandardCharsets.UTF_8);\n}","handlingStrategy":"type-guard","validationCode":"if (\"hdfs\".equalsIgnoreCase(uri.getScheme())) { /* do not call getCharContent */ }","typeGuard":"boolean supportsCharContent(FileObject fo) { return !isHdfsFileObject(fo); }","tryCatchPattern":"try { return fo.getCharContent(false); }\ncatch (UOE e) { return slurpInputStream(fo.openInputStream()); }","preventionTips":["Prefer openInputStream + explicit decoding for all HDFS text access.","Centralize FileObject usage so unsupported methods are never reachable from production code paths."],"tags":["hdfs","unsupported-operation","fileobject","charsequence"],"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"}