{"record":{"id":"83c96120fcc7b59b","repo":"apache/hadoop","slug":"decompress-called-on-closed-decompressor","errorCode":null,"errorMessage":"decompress called on closed decompressor","messagePattern":"decompress called on closed decompressor","errorType":"exception","errorClass":"AlreadyClosedException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java","lineNumber":195,"sourceCode":"  /* From the caller's perspective, this is where the state machine lives.\n   * The code is written such that we never return from decompress() with\n   * data remaining in userBuf unless we're in FINISHED state and there was\n   * data beyond the current gzip member (e.g., we're within a concatenated\n   * gzip stream).  If this ever changes, {@link #needsInput()} will also\n   * need to be modified (i.e., uncomment the userBufLen condition).\n   *\n   * The actual deflate-stream processing (decompression) is handled by\n   * Java's Inflater class.  Unlike the gzip header/trailer code (execute*\n   * methods below), the deflate stream is never copied; Inflater operates\n   * directly on the user's buffer.\n   */\n  @Override\n  public synchronized int decompress(byte[] b, int off, int len)\n  throws IOException {\n    int numAvailBytes = 0;\n\n    if (state == GzipStateLabel.ENDED) {\n      throw new AlreadyClosedException(\"decompress called on closed decompressor\");\n    }\n\n    if (state != GzipStateLabel.DEFLATE_STREAM) {\n      executeHeaderState();\n\n      if (userBufLen <= 0) {\n        return numAvailBytes;\n      }\n    }\n\n    // \"executeDeflateStreamState()\"\n    if (state == GzipStateLabel.DEFLATE_STREAM) {\n      // hand off user data (or what's left of it) to Inflater--but note that\n      // Inflater may not have consumed all of previous bufferload (e.g., if\n      // data highly compressed or output buffer very small), in which case\n      // userBufLen will be zero\n      if (userBufLen > 0) {\n        inflater.setInput(userBuf, userBufOff, userBufLen);","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java#L177-L213","documentation":"Error \"decompress called on closed decompressor\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java:195 when the library encounters an invalid state.","commonSituations":"Occurs when decompress() is called after the decompressor has been closed. Guard calls with the closed flag and create a new decompressor rather than reusing a closed one.","solutions":["Do not call decompress() after close(); allocate a new decompressor instead.","Ensure finish() and close() are invoked only after all input has been decompressed."],"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"}