{"record":{"id":"c3821fac5411e879","repo":"apache/druid","slug":"none-compression-strategy-shouldn-t-use-any-compre","errorCode":null,"errorMessage":"NONE compression strategy shouldn't use any compressor","messagePattern":"NONE compression strategy shouldn't use any compressor","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/data/CompressionStrategy.java","lineNumber":122,"sourceCode":"      return UncompressedCompressor.DEFAULT_COMPRESSOR;\n    }\n  },\n  /**\n   * This value indicate no compression strategy should be used, and compression should not be block based.\n   * {@link ColumnarLongs}, {@link ColumnarFloats} and {@link ColumnarDoubles} support non block based compression, and\n   * other types treat this as {@link #UNCOMPRESSED}.\n   */\n  NONE((byte) 0xFE) {\n    @Override\n    public Decompressor getDecompressor()\n    {\n      throw new UnsupportedOperationException(\"NONE compression strategy shouldn't use any decompressor\");\n    }\n\n    @Override\n    public Compressor getCompressor()\n    {\n      throw new UnsupportedOperationException(\"NONE compression strategy shouldn't use any compressor\");\n    }\n  };\n  private static final Logger LOG = new Logger(CompressionStrategy.class);\n\n  public static final CompressionStrategy DEFAULT_COMPRESSION_STRATEGY = LZ4;\n\n  final byte id;\n\n  CompressionStrategy(byte id)\n  {\n    this.id = id;\n  }\n\n  public byte getId()\n  {\n    return id;\n  }\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/data/CompressionStrategy.java#L104-L140","documentation":"The NONE CompressionStrategy stores data uncompressed, so it has no Compressor; getCompressor() throws UnsupportedOperationException. Writers must special-case NONE (or use UNCOMPRESSED, which supplies a no-op compressor) rather than requesting a compressor from it.","triggerScenarios":"Calling getCompressor() on CompressionStrategy.NONE, typically from a segment writer using a generic compression path while the config selects compression strategy NONE.","commonSituations":"Ingestion specs with compression: \"none\" flowing through code that unconditionally fetches a compressor; mixing NONE into APIs expecting a real compressor.","solutions":["Use CompressionStrategy.UNCOMPRESSED instead of NONE when a no-op compressor is needed","Check strategy == CompressionStrategy.NONE before calling getCompressor() and skip compression entirely","Change the ingestion spec compression to LZ4/ZSTD if compression is expected"],"exampleFix":"// before\nCompressor c = strategy.getCompressor();\n// after\nCompressor c = (strategy == CompressionStrategy.NONE)\n    ? CompressionStrategy.UNCOMPRESSED.getCompressor()\n    : strategy.getCompressor();","handlingStrategy":"type-guard","validationCode":"if (strategy == CompressionStrategy.NONE) { writeUncompressed(); } else { compress(); }","typeGuard":"if (strategy != CompressionStrategy.NONE) { Compressor c = strategy.getCompressor(); ... }","tryCatchPattern":"try {\n  c = strategy.getCompressor();\n} catch (UnsupportedOperationException e) {\n  c = CompressionStrategy.UNCOMPRESSED.getCompressor();\n}","preventionTips":["Prefer UNCOMPRESSED (no-op compressor) over NONE for writers","Special-case NONE before compressor acquisition","Set spec compression to a real strategy when compression is intended"],"tags":["java","compression","unsupported-operation"],"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"}