{"record":{"id":"ac6b03d21ff32e88","repo":"apache/cassandra","slug":"unsupported-operation","errorCode":null,"errorMessage":"unsupported operation","messagePattern":"unsupported operation","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java","lineNumber":197,"sourceCode":"            throw new FSReadError(e, getPath());\n        }\n    }\n\n    /**\n     * Get a quick estimation on how many bytes have been written to disk\n     *\n     * It should for the most part be exactly the same as getOnDiskFilePointer()\n     */\n    @Override\n    public long getEstimatedOnDiskBytesWritten()\n    {\n        return chunkOffset;\n    }\n\n    @Override\n    public void flush()\n    {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    protected void flushData()\n    {\n        // resetAndTruncate leaves fchannel.position() past EOF after its verification reads + truncate;\n        // re-seek so the next chunk lands at chunkOffset. No-op under linear writes.\n        seekToChunkStart();\n\n        try\n        {\n            // compressing data with buffer re-use\n            buffer.flip();\n            compressed.clear();\n            compressor.compress(buffer, compressed);\n        }\n        catch (IOException e)\n        {","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/compress/CompressedSequentialWriter.java#L179-L215","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the flush() call; use the writer's own completion path (finish()/close() or flushData()) which handles chunk boundaries and CRC correctly","If you need data on disk, call the compressed writer's flushData() instead of flush()","Ensure code that takes a SequentialWriter doesn't assume flush() exists for compressed variants — branch on the writer type"],"exampleFix":"// before\nCompressedSequentialWriter w = ...;\nw.flush(); // UnsupportedOperationException\n// after\nw.flushData(); // or w.finish(); w.close();","handlingStrategy":"type-guard","validationCode":"if (writer instanceof CompressedSequentialWriter) {\n    // do NOT call flush(); use flushData()/finish()\n}","typeGuard":"boolean supportsFlush(SequentialWriter w) {\n    return !(w instanceof CompressedSequentialWriter);\n}","tryCatchPattern":null,"preventionTips":["Treat flush() as unavailable on compressed writers; call finish()/close() or flushData()","When writing generic code over SequentialWriter, branch on the writer type before flushing","Prefer the try-with-resources close() path, which handles compressed completion correctly"],"tags":["compressed-writer","unsupported-api","io"],"backgroundTag":"unsupported-operation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}