{"record":{"id":"eab3c8bcb4d45ab6","repo":"apache/incubator-seata","slug":"bytes-is-null-eab3c8","errorCode":null,"errorMessage":"bytes is null","messagePattern":"bytes is null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"compressor/seata-compressor-lz4/src/main/java/org/apache/seata/compressor/lz4/Lz4Util.java","lineNumber":38,"sourceCode":"import net.jpountz.lz4.LZ4FrameOutputStream;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\n\n/**\n * the Lz4 Util\n *\n */\npublic class Lz4Util {\n    private static final Logger LOGGER = LoggerFactory.getLogger(Lz4Util.class);\n    private static final int ARRAY_SIZE = 1024;\n\n    public static byte[] compress(byte[] bytes) {\n        if (bytes == null) {\n            throw new NullPointerException(\"bytes is null\");\n        }\n        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();\n        try (LZ4FrameOutputStream lz4OutputStream = new LZ4FrameOutputStream(outputStream)) {\n            lz4OutputStream.write(bytes);\n        } catch (IOException e) {\n            LOGGER.error(\"compress bytes error\", e);\n        }\n        return outputStream.toByteArray();\n    }\n\n    public static byte[] decompress(byte[] bytes) {\n        if (bytes == null) {\n            throw new NullPointerException(\"bytes is null\");\n        }\n\n        ByteArrayOutputStream outputStream = new ByteArrayOutputStream(ARRAY_SIZE);\n        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);\n        try (LZ4FrameInputStream decompressedInputStream = new LZ4FrameInputStream(inputStream)) {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/compressor/seata-compressor-lz4/src/main/java/org/apache/seata/compressor/lz4/Lz4Util.java#L20-L56","documentation":"Thrown by Lz4Util.compress when the input byte array is null. The lz4 compressor is used to shrink seata RPC message bodies before transport; compress requires a non-null input and signals null as a caller bug via NullPointerException('bytes is null'). Note that unlike gzip, the IOException path in lz4 compress only logs the error and returns whatever partial bytes exist — but this error is the null guard.","triggerScenarios":"Calling Lz4Util.compress(null), or a seata transport/serializer handing a null body to the lz4 Compressor because the message field was never set.","commonSituations":"Building seata RPC messages manually in tests or SDK extensions without a body; a codec path where an optional payload field is absent; switching message types where one type has no body.","solutions":["Find why the body is null — log the message construction site that passed the null field.","Send an empty array instead of null when 'no payload' is intended.","Null-check before compress and fail with a descriptive error naming the message type."],"exampleFix":"// before\nbyte[] out = Lz4Util.compress(bytes);\n\n// after\nbyte[] out = Lz4Util.compress(bytes == null ? new byte[0] : bytes);","handlingStrategy":"validation","validationCode":"if (bytes == null) {\n    throw new IllegalArgumentException(\"payload to lz4-compress is null\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use empty arrays, not null, for intentionally empty payloads","Validate message bodies at construction time, not at compression time"],"tags":["lz4","compression","null-safety","seata"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}