{"record":{"id":"c5c44da51be6ddec","repo":"apache/incubator-seata","slug":"bytes-is-null-c5c44d","errorCode":null,"errorMessage":"bytes is null","messagePattern":"bytes is null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"compressor/seata-compressor-zstd/src/main/java/org/apache/seata/compressor/zstd/ZstdUtil.java","lineNumber":34,"sourceCode":" */\npackage org.apache.seata.compressor.zstd;\n\nimport com.github.luben.zstd.Zstd;\nimport com.github.luben.zstd.ZstdInputStream;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\n\n/**\n * the Zstd Util\n *\n */\npublic class ZstdUtil {\n\n    public static byte[] compress(byte[] bytes) {\n        if (bytes == null) {\n            throw new NullPointerException(\"bytes is null\");\n        }\n\n        return Zstd.compress(bytes);\n    }\n\n    public static byte[] decompress(byte[] bytes) {\n        if (bytes == null) {\n            throw new NullPointerException(\"bytes is null\");\n        }\n        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);\n                ZstdInputStream zis = new ZstdInputStream(bais);\n                ByteArrayOutputStream baos = new ByteArrayOutputStream()) {\n            byte[] buffer = new byte[8192];\n            int len;\n            while ((len = zis.read(buffer)) > 0) {\n                baos.write(buffer, 0, len);\n            }\n            return baos.toByteArray();","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/compressor/seata-compressor-zstd/src/main/java/org/apache/seata/compressor/zstd/ZstdUtil.java#L16-L52","documentation":"Thrown by ZstdUtil.compress when the input byte array is null. The zstd compressor delegates to the native Zstd bindings after the null guard; null input is rejected with NullPointerException('bytes is null') because the native call would otherwise crash the JVM.","triggerScenarios":"Calling ZstdUtil.compress(null) or the Compressor framework passing a null message body into the zstd path.","commonSituations":"Missing optional body on deserialized RPC messages; tests passing null; codec extension code that skips body population for some message types.","solutions":["Find the construction site of the null body and log the message type.","Use an empty array to represent an intentionally empty payload.","Add a null guard with context-rich error before compress."],"exampleFix":"// before\nbyte[] out = ZstdUtil.compress(bytes);\n\n// after\nif (bytes == null) {\n    throw new IllegalArgumentException(\"payload to zstd-compress is null\");\n}\nbyte[] out = ZstdUtil.compress(bytes);","handlingStrategy":"validation","validationCode":"if (bytes == null) {\n    throw new IllegalArgumentException(\"payload to zstd-compress is null\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never let null bodies reach native-backed compressors (zstd/lz4) — guard in your codec layer","Prefer empty arrays for empty payloads"],"tags":["zstd","compression","null-safety","seata"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}