apache/druid · error · UnsupportedOperationException

CharSequence not supported

Error message

CharSequence not supported

What it means

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.

Solutions

  1. Don't call getCharContent on this FileObject; open it as bytes instead (openInputStream) and read the zip binary.
  2. Copy the file to a regular File and read text from there if a CharSequence is required.
  3. Guard calls: check the FileObject implementation and fall back to a byte-stream reader.

Example fix

// before
CharSequence text = fileObject.getCharContent(true);
// after
try (InputStream in = fileObject.openInputStream()) {
  byte[] data = ByteStreams.toByteArray(in); // read segment as bytes
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  CharSequence cs = fileObject.getCharContent(true);
} catch (UnsupportedOperationException e) {
  try (InputStream in = fileObject.openInputStream()) {
    byte[] bytes = in.readAllBytes(); // handle segment as binary
  }
}

Prevention

When it happens

Trigger: Calling getCharContent(ignoreEncodingErrors) on the FileObject returned by LocalDataSegmentPuller.get() — typically from tooling or extension code that tries to read the zip as text.

Common situations: Compiler/annotation-processing style tooling (javax.tools.FileObject consumers) applied to segment archives; custom code assuming all FileObjects support text reads.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/344eb3f7b22dfa13. Report an issue: GitHub.

Appendix: source

Thrown at server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPuller.java:94

        return new FileInputStream(file);
      }

      @Override
      public OutputStream openOutputStream() throws IOException
      {
        return new FileOutputStream(file);
      }

      @Override
      public Reader openReader(boolean ignoreEncodingErrors) throws IOException
      {
        return Files.newReader(file, Charset.defaultCharset());
      }

      @Override
      public CharSequence getCharContent(boolean ignoreEncodingErrors)
      {
        throw new UOE("CharSequence not supported");
      }

      @Override
      public Writer openWriter() throws IOException
      {
        return Files.newWriter(file, Charset.defaultCharset());
      }

      @Override
      public long getLastModified()
      {
        return file.lastModified();
      }

      @Override
      public boolean delete()
      {
        return file.delete();

View on GitHub (pinned to 9b90983fd2)