apache/incubator-seata · error · NullPointerException
bytes is null
Error message
bytes is null
What it means
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'.
Source
Thrown at compressor/seata-compressor-zip/src/main/java/org/apache/seata/compressor/zip/ZipUtil.java:36
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
/**
* the Zip Util
*
*/
public class ZipUtil {
private static final int BUFFER_SIZE = 8192;
public static byte[] compress(byte[] bytes) {
if (bytes == null) {
throw new NullPointerException("bytes is null");
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ZipOutputStream zip = new ZipOutputStream(out)) {
ZipEntry entry = new ZipEntry("zip");
entry.setSize(bytes.length);
zip.putNextEntry(entry);
zip.write(bytes);
zip.closeEntry();
return out.toByteArray();
} catch (IOException e) {
throw new RuntimeException("Zip compress error", e);
}
}
public static byte[] decompress(byte[] bytes) {
if (bytes == null) {
throw new NullPointerException("bytes is null");
}View on GitHub (pinned to e01f97c6db)
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.
Example fix
// before
byte[] out = ZipUtil.compress(bytes);
// after
if (bytes == null) {
throw new IllegalArgumentException("payload to zip is null; check message construction");
}
byte[] out = ZipUtil.compress(bytes); Defensive patterns
Strategy: validation
Validate before calling
if (bytes == null) {
throw new IllegalArgumentException("payload to zip-compress is null");
} Prevention
- Centralize body validation in one serializer layer instead of each compressor
- Use empty array for empty payload semantics
When it happens
Trigger: Calling ZipUtil.compress(null), or the seata Compressor framework invoking zip compression on a message body that was never set.
Common situations: Hand-constructed RPC messages in SDK code or tests with a missing body; codec paths where the payload field is optional and absent.
Related errors
AI-assisted analysis of apache/incubator-seata@e01f97c6db (2026-08-14).
Data as JSON: /api/errors/3e609857c92415fc.
Report an issue: GitHub.