apache/druid · error · UnsupportedOperationException

Directory compression not supported for %s

Error message

Directory compression not supported for %s

What it means

CompressionUtils.CompressionFormat.compressDirectory is a default method that throws UnsupportedOperationException; only formats that actually support compressing a whole directory (e.g. gzip/tgz, zip) override it. Calling it on a format such as LZ4 or ZSTD (which support only stream compression via this default) throws this error. It is a deliberate capability gate, not a runtime failure.

Source

Thrown at processing/src/main/java/org/apache/druid/utils/CompressionUtils.java:180

      if (null == extension) {
        return null;
      }
      return EXTENSION_TO_COMPRESSION_FORMAT.get(extension);
    }

    /**
     * Compresses a directory to the output stream. Default implementation throws UnsupportedOperationException.
     * Override this method for formats that support directory compression.
     *
     * @param directory The directory to compress
     * @param out The output stream to write compressed data to
     * @return The number of bytes (uncompressed) read from the input directory
     * @throws IOException if an I/O error occurs
     * @throws UnsupportedOperationException if the format doesn't support directory compression
     */
    public long compressDirectory(File directory, OutputStream out) throws IOException
    {
      throw new UnsupportedOperationException("Directory compression not supported for " + this.name());
    }

    /**
     * Decompresses a directory from the input stream. Default implementation throws UnsupportedOperationException.
     * Override this method for formats that support directory decompression.
     *
     * @param in The input stream containing compressed data
     * @param outDir The output directory to extract files to
     * @return A FileCopyResult containing information about extracted files
     * @throws IOException if an I/O error occurs
     * @throws UnsupportedOperationException if the format doesn't support directory decompression
     */
    public FileUtils.FileCopyResult decompressDirectory(InputStream in, File outDir) throws IOException
    {
      throw new UnsupportedOperationException("Directory decompression not supported for " + this.name());
    }
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Check format support before calling, e.g. switch on the format and use the dedicated lz4/zstd stream-compression helpers
  2. Use a directory-capable format (GZIP/tgz or ZIP) when a whole directory must be compressed
  3. Wrap the call in try/catch for UnsupportedOperationException and fall back to per-file compression
  4. Confirm the Druid version's CompressionFormat overrides for your chosen format

Example fix

// before
new CompressionUtils.CompressionFormat.LZ4().compressDirectory(dir, out); // throws
// after
CompressionUtils.lz4CompressDirectory(dir, out); // dedicated stream compressor
// or use GZIP: CompressionUtils.gzipDirectory? -> CompressionUtils.zip(dir, out);
Defensive patterns

Strategy: fallback

Try / catch

try {
  format.compressDirectory(dir, out);
} catch (UnsupportedOperationException e) {
  // fall back to per-file compression or a supported format
}

Prevention

When it happens

Trigger: Calling compressDirectory on a CompressionFormat enum value whose directory-compression method was not overridden — e.g. format LZ4 or ZSTD in CompressionUtils — instead of using lz4CompressDirectory/zstdCompressDirectory or a supported format like GZIP/ZIP.

Common situations: Generic backup/job code that iterates formats and calls compressDirectory without checking support; config selecting a compression format that lacks directory support; newer formats added before the directory methods were implemented.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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