{"record":{"id":"1cc0b463f65e2392","repo":"apache/druid","slug":"hdfs-writer-not-supported","errorCode":null,"errorMessage":"HDFS Writer not supported","messagePattern":"HDFS Writer 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":152,"sourceCode":"        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        }\n      }\n\n      @Override\n      public boolean delete()\n      {\n        try {","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPuller.java#L134-L170","documentation":"The HDFS FileObject's openWriter() throws UOE(\"HDFS Writer not supported\"): character/Writer-based output to HDFS is deliberately not implemented in this FileObject adapter. Writes must go through openOutputStream(), which returns a real OutputStream backed by FileSystem.create. The exception is thrown unconditionally whenever openWriter is invoked.","triggerScenarios":"Invoking openWriter() on the FileObject from HdfsDataSegmentPuller.buildFileObject(uri, config, overwrite) — e.g. code that writes text artifacts (logs, descriptors) via the generic FileObject Writer API against hdfs:// URIs.","commonSituations":"Porting local-disk writing code to HDFS deep storage; utility libraries that take a FileObject and prefer openWriter for character output.","solutions":["Use openOutputStream() and wrap it in an OutputStreamWriter/PrintWriter if character writing is needed.","Keep byte-level writes for HDFS targets; reserve Writer-based APIs for local or HTTP pullers.","Branch on URI scheme before writing and route hdfs:// to the OutputStream API."],"exampleFix":"// before\ntry (Writer w = fileObject.openWriter()) { w.write(json); }\n// after\ntry (Writer w = new OutputStreamWriter(fileObject.openOutputStream(), StandardCharsets.UTF_8)) { w.write(json); }","handlingStrategy":"type-guard","validationCode":"if (\"hdfs\".equalsIgnoreCase(uri.getScheme())) { writeViaOutputStream(uri, data); }","typeGuard":"boolean supportsWriter(FileObject fo) { return !isHdfsFileObject(fo); }","tryCatchPattern":"try (Writer w = fo.openWriter()) { w.write(s); }\ncatch (UOE e) { try (Writer w = new OutputStreamWriter(fo.openOutputStream(), UTF_8)) { w.write(s); } }","preventionTips":["Use openOutputStream (optionally wrapped in OutputStreamWriter) for all HDFS writes.","Pass the desired overwrite flag to buildFileObject so stream creation behaves as expected."],"tags":["hdfs","unsupported-operation","fileobject","writer"],"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"}