{"record":{"id":"04d09e96a0c399f8","repo":"apache/incubator-seata","slug":"deflater-decompress-error","errorCode":null,"errorMessage":"Deflater decompress error","messagePattern":"Deflater decompress error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"compressor/seata-compressor-deflater/src/main/java/org/apache/seata/compressor/deflater/DeflaterUtil.java","lineNumber":70,"sourceCode":"        if (bytes == null) {\n            throw new NullPointerException(\"bytes is null\");\n        }\n        int length = 0;\n        Inflater inflater = new Inflater();\n        inflater.setInput(bytes);\n        byte[] outputBytes = new byte[BUFFER_SIZE];\n        try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {\n            while (!inflater.finished()) {\n                length = inflater.inflate(outputBytes);\n                if (length == 0) {\n                    break;\n                }\n                bos.write(outputBytes, 0, length);\n            }\n            inflater.end();\n            return bos.toByteArray();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Deflater decompress error\", e);\n        }\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/compressor/seata-compressor-deflater/src/main/java/org/apache/seata/compressor/deflater/DeflaterUtil.java#L52-L74","documentation":"DeflaterUtil.decompress catches Exception — notably java.util.zip.DataFormatException — and rethrows RuntimeException('Deflater decompress error'). DataFormatException means the buffer is not valid zlib/deflate data: wrong compressor on the producer, corrupted/truncated payload, or raw bytes passed where compressed bytes were expected. The broad catch also covers premature end-of-stream cases handled by the internal length==0 break.","triggerScenarios":"decompress(bytes) where bytes was produced by gzip/bzip2/zstd or not compressed at all (compressor id mismatch between Seata peers), truncated by a size limit, or corrupted in transit; the Inflater constructor rejects the header on first inflate() call.","commonSituations":"Changing seata compressor settings on the client but not the server (or rolling restart leaving mixed versions); payloads mangled by text-mode transports (e.g. sent as ISO-8859-1 strings); undo logs written before compression enabled then read with deflater on.","solutions":["Set identical compressor configuration on all peers (client transport, server transport, undo_log compressor) and do a synchronized restart/rollout.","Sanity-check the payload: raw deflate streams from Seata start with a zlib header (first byte usually 0x78); anything else indicates a different algorithm.","Verify byte-for-byte transport (base64 or safe binary framing) end to end.","Catch RuntimeException and inspect getCause() — DataFormatException confirms bad data rather than a Seata bug."],"exampleFix":"// before\n byte[] raw = DeflaterUtil.decompress(body);\n\n// after\n try {\n     byte[] raw = DeflaterUtil.decompress(body);\n } catch (RuntimeException e) {\n     if (e.getCause() instanceof DataFormatException) {\n         throw new IOException(\"payload is not valid deflate data — check compressor config on both peers\", e.getCause());\n     }\n     throw e;\n }","handlingStrategy":"try-catch","validationCode":"// zlib streams (JDK Deflater default) typically start with 0x78\npublic static boolean looksLikeZlib(byte[] data) {\n    return data != null && data.length >= 2 && data[0] == 0x78;\n}","typeGuard":null,"tryCatchPattern":"try {\n    return DeflaterUtil.decompress(bytes);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof java.util.zip.DataFormatException) {\n        throw new IOException(\"payload is not valid deflate data — \"\n            + \"check that both peers use the same compressor\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Never change seata compressor settings on one side only; plan synchronized restarts.","Transport compressed bytes as raw binary or base64 — never through lossy text conversions.","Check DataFormatException in the cause chain to distinguish bad data from environment faults."],"tags":["compressor","deflater","data-corruption","configuration-mismatch"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}