{"record":{"id":"f5810ec33a1fc449","repo":"MuntashirAkon/AppManager","slug":"bzip2-crc-error","errorCode":null,"errorMessage":"BZip2 CRC error","messagePattern":"BZip2 CRC error","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java","lineNumber":328,"sourceCode":"        // currBlockNo++;\n        getAndMoveToFrontDecode();\n\n        this.crc.initializeCRC();\n        this.currentState = START_BLOCK_STATE;\n    }\n\n    private void endBlock() throws IOException {\n        this.computedBlockCRC = this.crc.getFinalCRC();\n\n        // A bad CRC is considered a fatal error.\n        if (this.storedBlockCRC != this.computedBlockCRC) {\n            // make next blocks readable without error\n            // (repair feature, not yet documented, not tested)\n            this.computedCombinedCRC = (this.storedCombinedCRC << 1)\n                    | (this.storedCombinedCRC >>> 31);\n            this.computedCombinedCRC ^= this.storedBlockCRC;\n\n            throw new IOException(\"BZip2 CRC error\");\n        }\n\n        this.computedCombinedCRC = (this.computedCombinedCRC << 1)\n                | (this.computedCombinedCRC >>> 31);\n        this.computedCombinedCRC ^= this.computedBlockCRC;\n    }\n\n    private boolean complete() throws IOException {\n        this.storedCombinedCRC = bsGetInt(bin);\n        this.currentState = EOF;\n        this.data = null;\n\n        if (this.storedCombinedCRC != this.computedCombinedCRC) {\n            throw new IOException(\"BZip2 CRC error\");\n        }\n\n        // Look for the next .bz2 stream if decompressing\n        // concatenated files.","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java#L310-L346","documentation":"endBlock() compares the block's stored CRC with the computed CRC of the decompressed bytes and throws IOException(\"BZip2 CRC error\") on mismatch. This detects that the decompressed block differs from what the compressor recorded — data corruption during decompression.","triggerScenarios":"A compressed block whose bits were corrupted between compression and decompression; a truncated/mutated .bz2 file; memory or transfer corruption during read.","commonSituations":"Flaky network transfers without end-to-end checksums; failing disks; downloading .bz2 over ASCII-mode FTP that mangled bytes; corrupted attachments.","solutions":["Re-download or re-extract the file from a trusted source and compare checksums.","Verify with `bzip2 -tv file.bz2` before processing.","If the error occurs at a known offset mid-file, recover earlier complete blocks only if you control the format (multiple concatenated streams)."],"exampleFix":"// before\nprocess(new BZip2CompressorInputStream(new FileInputStream(bz2File)));\n// after\nif (!verifyBz2(bz2File)) { // runs bzip2 -tv or checks md5 against manifest\n    throw new IOException(\"Corrupt archive: \" + bz2File);\n}\nprocess(new BZip2CompressorInputStream(new FileInputStream(bz2File)));","handlingStrategy":"try-catch","validationCode":"// pre-flight integrity check (out of JVM)\n// bzip2 -tv file.bz2  OR  compare stored md5/sha256 manifest","typeGuard":null,"tryCatchPattern":"try {\n    decompress(in);\n} catch (IOException e) {\n    if (String.valueOf(e.getMessage()).contains(\"CRC error\")) {\n        // mark source as corrupt; re-fetch or quarantine\n        throw new DataCorruptionException(e);\n    }\n    throw e;\n}","preventionTips":["Compare checksums of transferred .bz2 files against the publisher.","Avoid transfers that can transform bytes (ASCII FTP mode, mail encoding).","Fail fast on CRC errors; do not attempt to salvage the block."],"tags":["io","corruption","crc"],"backgroundTag":"checksum-mismatch","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}