{"record":{"id":"344eb3f7b22dfa13","repo":"apache/druid","slug":"charsequence-not-supported","errorCode":null,"errorMessage":"CharSequence not supported","messagePattern":"CharSequence not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPuller.java","lineNumber":94,"sourceCode":"        return new FileInputStream(file);\n      }\n\n      @Override\n      public OutputStream openOutputStream() throws IOException\n      {\n        return new FileOutputStream(file);\n      }\n\n      @Override\n      public Reader openReader(boolean ignoreEncodingErrors) throws IOException\n      {\n        return Files.newReader(file, Charset.defaultCharset());\n      }\n\n      @Override\n      public CharSequence getCharContent(boolean ignoreEncodingErrors)\n      {\n        throw new UOE(\"CharSequence not supported\");\n      }\n\n      @Override\n      public Writer openWriter() throws IOException\n      {\n        return Files.newWriter(file, Charset.defaultCharset());\n      }\n\n      @Override\n      public long getLastModified()\n      {\n        return file.lastModified();\n      }\n\n      @Override\n      public boolean delete()\n      {\n        return file.delete();","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPuller.java#L76-L112","documentation":"When pulling a local segment, LocalDataSegmentPuller exposes the segment archive as a JavaCompiler FileObject for tools that inspect it. getCharContent is deliberately unimplemented for this FileObject, so any caller requesting the file's character content receives this UnsupportedOperationException.","triggerScenarios":"Calling getCharContent(ignoreEncodingErrors) on the FileObject returned by LocalDataSegmentPuller.get() — typically from tooling or extension code that tries to read the zip as text.","commonSituations":"Compiler/annotation-processing style tooling (javax.tools.FileObject consumers) applied to segment archives; custom code assuming all FileObjects support text reads.","solutions":["Don't call getCharContent on this FileObject; open it as bytes instead (openInputStream) and read the zip binary.","Copy the file to a regular File and read text from there if a CharSequence is required.","Guard calls: check the FileObject implementation and fall back to a byte-stream reader."],"exampleFix":"// before\nCharSequence text = fileObject.getCharContent(true);\n// after\ntry (InputStream in = fileObject.openInputStream()) {\n  byte[] data = ByteStreams.toByteArray(in); // read segment as bytes\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  CharSequence cs = fileObject.getCharContent(true);\n} catch (UnsupportedOperationException e) {\n  try (InputStream in = fileObject.openInputStream()) {\n    byte[] bytes = in.readAllBytes(); // handle segment as binary\n  }\n}","preventionTips":["Treat segment archives as binary; never request text content from FileObjects wrapping zips.","Read via openInputStream when inspecting pulled segments."],"tags":["unsupported-operation","fileobject","segment-pull"],"backgroundTag":"method-not-implemented","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"}