{"record":{"id":"3e609857c92415fc","repo":"apache/incubator-seata","slug":"bytes-is-null-3e6098","errorCode":null,"errorMessage":"bytes is null","messagePattern":"bytes is null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"compressor/seata-compressor-zip/src/main/java/org/apache/seata/compressor/zip/ZipUtil.java","lineNumber":36,"sourceCode":"\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.util.zip.ZipEntry;\nimport java.util.zip.ZipInputStream;\nimport java.util.zip.ZipOutputStream;\n\n/**\n * the Zip Util\n *\n */\npublic class ZipUtil {\n\n    private static final int BUFFER_SIZE = 8192;\n\n    public static byte[] compress(byte[] bytes) {\n        if (bytes == null) {\n            throw new NullPointerException(\"bytes is null\");\n        }\n        ByteArrayOutputStream out = new ByteArrayOutputStream();\n        try (ZipOutputStream zip = new ZipOutputStream(out)) {\n            ZipEntry entry = new ZipEntry(\"zip\");\n            entry.setSize(bytes.length);\n            zip.putNextEntry(entry);\n            zip.write(bytes);\n            zip.closeEntry();\n            return out.toByteArray();\n        } catch (IOException e) {\n            throw new RuntimeException(\"Zip compress error\", e);\n        }\n    }\n\n    public static byte[] decompress(byte[] bytes) {\n        if (bytes == null) {\n            throw new NullPointerException(\"bytes is null\");\n        }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/compressor/seata-compressor-zip/src/main/java/org/apache/seata/compressor/zip/ZipUtil.java#L18-L54","documentation":"Thrown by ZipUtil.compress when the input byte array is null. The zip compressor wraps payloads in a single-entry zip stream; compress rejects null immediately with NullPointerException('bytes is null') because there is no meaningful zip representation of 'nothing'.","triggerScenarios":"Calling ZipUtil.compress(null), or the seata Compressor framework invoking zip compression on a message body that was never set.","commonSituations":"Hand-constructed RPC messages in SDK code or tests with a missing body; codec paths where the payload field is optional and absent.","solutions":["Log the message construction site to find why the body is null.","Pass an empty array if 'empty payload' is the intent.","Add a null guard with a descriptive error before compress."],"exampleFix":"// before\nbyte[] out = ZipUtil.compress(bytes);\n\n// after\nif (bytes == null) {\n    throw new IllegalArgumentException(\"payload to zip is null; check message construction\");\n}\nbyte[] out = ZipUtil.compress(bytes);","handlingStrategy":"validation","validationCode":"if (bytes == null) {\n    throw new IllegalArgumentException(\"payload to zip-compress is null\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize body validation in one serializer layer instead of each compressor","Use empty array for empty payload semantics"],"tags":["zip","compression","null-safety","seata"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}