{"record":{"id":"37701001c16457ef","repo":"apache/druid","slug":"none-compression-strategy-shouldn-t-use-any-decomp","errorCode":null,"errorMessage":"NONE compression strategy shouldn't use any decompressor","messagePattern":"NONE compression strategy shouldn't use any decompressor","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/data/CompressionStrategy.java","lineNumber":116,"sourceCode":"      return UncompressedDecompressor.DEFAULT_DECOMPRESSOR;\n    }\n\n    @Override\n    public Compressor getCompressor()\n    {\n      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  }","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/data/CompressionStrategy.java#L98-L134","documentation":"CompressionStrategy.NONE means data is stored uncompressed, so requesting a Decompressor from it is by definition invalid; the enum method throws UnsupportedOperationException. Callers must handle NONE before obtaining a decompressor.","triggerScenarios":"Calling compressionStrategy.getDecompressor() when the strategy is CompressionStrategy.NONE, e.g. after loading a segment whose metadata declares no compression.","commonSituations":"Generic decompression code paths that fail to special-case uncompressed segments; segments written with compression: \"none\" in the ingestion spec then read by code assuming compression.","solutions":["Branch on the strategy before decompressing: if strategy == CompressionStrategy.NONE, copy bytes without a Decompressor","Use CompressionStrategy.UNCOMPRESSED instead of NONE in generic paths, since it returns a pass-through decompressor","If the segment metadata unexpectedly says NONE, fix the ingestion spec that wrote it"],"exampleFix":"// before\nDecompressor d = strategy.getDecompressor();\n// after\nDecompressor d = (strategy == CompressionStrategy.NONE)\n    ? CompressionStrategy.UNCOMPRESSED.getDecompressor()\n    : strategy.getDecompressor();","handlingStrategy":"type-guard","validationCode":"if (strategy == CompressionStrategy.NONE) { skipDecompression(); }","typeGuard":"if (strategy != CompressionStrategy.NONE) { Decompressor d = strategy.getDecompressor(); ... }","tryCatchPattern":"try {\n  d = strategy.getDecompressor();\n} catch (UnsupportedOperationException e) {\n  d = CompressionStrategy.UNCOMPRESSED.getDecompressor();\n}","preventionTips":["Use UNCOMPRESSED rather than NONE in generic code paths","Always branch on strategy before requesting a decompressor","Document that NONE is reader/writer plumbing only"],"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"}