{"record":{"id":"5856267b733a0fee","repo":"apache/hadoop","slug":"compress-called-on-closed-compressor","errorCode":null,"errorMessage":"compress called on closed compressor","messagePattern":"compress called on closed compressor","errorType":"exception","errorClass":"AlreadyClosedException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipCompressor.java","lineNumber":88,"sourceCode":"  @Override\n  public boolean finished() {\n    // Only if the trailer is also written, it is thought as finished.\n    return state == BuiltInGzipDecompressor.GzipStateLabel.FINISHED && deflater.finished();\n  }\n\n  @Override\n  public boolean needsInput() {\n    return deflater.needsInput() && state != BuiltInGzipDecompressor.GzipStateLabel.TRAILER_CRC;\n  }\n\n  @Override\n  public int compress(byte[] b, int off, int len) throws IOException {\n    if (finished()) {\n      throw new IOException(\"compress called on finished compressor\");\n    }\n\n    if (state == BuiltInGzipDecompressor.GzipStateLabel.ENDED) {\n      throw new AlreadyClosedException(\"compress called on closed compressor\");\n    }\n\n    int compressedBytesWritten = 0;\n\n    // If we are not within uncompressed data yet, output the header.\n    if (state == BuiltInGzipDecompressor.GzipStateLabel.HEADER_BASIC) {\n      int outputHeaderSize = writeHeader(b, off, len);\n      numExtraBytesWritten += outputHeaderSize;\n\n      compressedBytesWritten += outputHeaderSize;\n\n      if (outputHeaderSize == len) {\n        return compressedBytesWritten;\n      }\n\n      off += outputHeaderSize;\n      len -= outputHeaderSize;\n    }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipCompressor.java#L70-L106","documentation":"Error \"compress called on closed compressor\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipCompressor.java:88 when the library encounters an invalid state.","commonSituations":"Occurs when compress() is called after the compressor has been closed. Check the closed flag before use and do not reuse a compressor after close(); create a new instance instead.","solutions":["Do not call compress() after close(); create a new BuiltInGzipCompressor if compression must resume.","Guard compress calls with a state check or try/finally so close() runs only after all compress() calls complete."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}