{"record":{"id":"00e6ee9fd209e2fc","repo":"apache/hadoop","slug":"gzip-stream-crc-failure","errorCode":null,"errorMessage":"gzip stream CRC failure","messagePattern":"gzip stream CRC failure","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java","lineNumber":384,"sourceCode":"   */\n  private void executeTrailerState() throws IOException {\n\n    if (userBufLen <= 0) {\n      return;\n    }\n\n    // verify that the CRC-32 of the decompressed stream matches the value\n    // stored in the gzip trailer\n    if (state == GzipStateLabel.TRAILER_CRC) {\n      // localBuf was empty before we handed off to Inflater, so we handle this\n      // exactly like header fields\n      assert (localBufOff < 4);  // initially 0, but may need multiple calls\n      int n = Math.min(userBufLen, 4-localBufOff);\n      copyBytesToLocal(n);\n      if (localBufOff >= 4) {\n        long streamCRC = readUIntLE(localBuf, 0);\n        if (streamCRC != crc.getValue()) {\n          throw new IOException(\"gzip stream CRC failure\");\n        }\n        localBufOff = 0;\n        crc.reset();\n        state = GzipStateLabel.TRAILER_SIZE;\n      }\n    }\n\n    if (userBufLen <= 0) {\n      return;\n    }\n\n    // verify that the mod-2^32 decompressed stream size matches the value\n    // stored in the gzip trailer\n    if (state == GzipStateLabel.TRAILER_SIZE) {\n      assert (localBufOff < 4);  // initially 0, but may need multiple calls\n      int n = Math.min(userBufLen, 4-localBufOff);\n      copyBytesToLocal(n);       // modifies userBufLen, etc.\n      if (localBufOff >= 4) {    // should be strictly ==","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java#L366-L402","documentation":"Error \"gzip stream CRC failure\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java:384 when the library encounters an invalid state.","commonSituations":"Occurs when the gzip stream CRC32 does not match the trailer, indicating corrupt or truncated data. Verify file integrity upstream and catch IOException to retry or fail cleanly.","solutions":["The stream CRC does not match the data; the gzip file is corrupted. Re-create or re-download it.","Check for truncation: compare file size with the expected size and retry the transfer."],"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"}