apache/cassandra · error · UnsupportedOperationException

unsupported operation

Error message

unsupported operation

What it means

CompressedSequentialWriter does not support the plain SequentialWriter flush() semantics because compressed output is buffered per chunk and flushed through flushData(). Calling flush() directly would break the chunk/CRC bookkeeping, so the method deliberately throws UnsupportedOperationException.

Source

Thrown at src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java:197

            throw new FSReadError(e, getPath());
        }
    }

    /**
     * Get a quick estimation on how many bytes have been written to disk
     *
     * It should for the most part be exactly the same as getOnDiskFilePointer()
     */
    @Override
    public long getEstimatedOnDiskBytesWritten()
    {
        return chunkOffset;
    }

    @Override
    public void flush()
    {
        throw new UnsupportedOperationException();
    }

    @Override
    protected void flushData()
    {
        // resetAndTruncate leaves fchannel.position() past EOF after its verification reads + truncate;
        // re-seek so the next chunk lands at chunkOffset. No-op under linear writes.
        seekToChunkStart();

        try
        {
            // compressing data with buffer re-use
            buffer.flip();
            compressed.clear();
            compressor.compress(buffer, compressed);
        }
        catch (IOException e)
        {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Remove the flush() call; use the writer's own completion path (finish()/close() or flushData()) which handles chunk boundaries and CRC correctly
  2. If you need data on disk, call the compressed writer's flushData() instead of flush()
  3. Ensure code that takes a SequentialWriter doesn't assume flush() exists for compressed variants — branch on the writer type

Example fix

// before
CompressedSequentialWriter w = ...;
w.flush(); // UnsupportedOperationException
// after
w.flushData(); // or w.finish(); w.close();
Defensive patterns

Strategy: type-guard

Validate before calling

if (writer instanceof CompressedSequentialWriter) {
    // do NOT call flush(); use flushData()/finish()
}

Type guard

boolean supportsFlush(SequentialWriter w) {
    return !(w instanceof CompressedSequentialWriter);
}

Prevention

When it happens

Trigger: Application or internal code calling flush() on a CompressedSequentialWriter instance (e.g. after writes expecting data to hit disk), rather than the compressed-writer-specific finish/flushData path.

Common situations: Custom code reusing Cassandra's SequentialWriter API generically and calling flush() on a compressed stream; internal refactors that mix compressed and uncompressed writer code paths.

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/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/ac6b03d21ff32e88. Report an issue: GitHub.