apache/incubator-seata · error · RuntimeException
Zip decompress error
Error message
Zip decompress error
What it means
Wrapped IOException from ZipUtil.decompress thrown as RuntimeException('Zip decompress error', e). It fires when ZipInputStream cannot parse the payload: not a zip stream, truncated data, unsupported compression method, or a corrupt entry header. The original exception is preserved as cause.
Source
Thrown at compressor/seata-compressor-zip/src/main/java/org/apache/seata/compressor/zip/ZipUtil.java:66
}
}
public static byte[] decompress(byte[] bytes) {
if (bytes == null) {
throw new NullPointerException("bytes is null");
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ZipInputStream zip = new ZipInputStream(new ByteArrayInputStream(bytes))) {
byte[] buffer = new byte[BUFFER_SIZE];
while (zip.getNextEntry() != null) {
int n;
while ((n = zip.read(buffer)) > -1) {
out.write(buffer, 0, n);
}
}
return out.toByteArray();
} catch (IOException e) {
throw new RuntimeException("Zip decompress error", e);
}
}
}
View on GitHub (pinned to e01f97c6db)
Solutions
- Check the cause: ZipException 'Not in ZIP format' = wrong codec, 'unexpected EOF' = truncation.
- Align compressor configuration on client and server.
- Regenerate or purge corrupted stored data instead of retrying.
- Preflight the payload with a zip magic check (PK\x03\x04) when data provenance is uncertain.
Example fix
// before
byte[] out = ZipUtil.decompress(bytes);
// after
if (bytes.length < 4 || bytes[0] != 'P' || bytes[1] != 'K') {
throw new IllegalArgumentException("payload is not a zip stream");
}
byte[] out = ZipUtil.decompress(bytes); Defensive patterns
Strategy: try-catch
Validate before calling
boolean isZip(byte[] b) {
return b != null && b.length >= 4 && b[0] == 'P' && b[1] == 'K';
} Try / catch
try {
byte[] out = ZipUtil.decompress(bytes);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains("Zip decompress error")) {
// wrong codec or truncated data; inspect e.getCause() (ZipException) and reject
} else { throw e; }
} Prevention
- Align compressor type on all endpoints before enabling compression
- Check the PK magic bytes when decompressing data from untrusted stores
- Purge/regenerate corrupted persisted payloads rather than retrying decompression
When it happens
Trigger: Passing gzip/lz4/zstd-compressed bytes to the zip decompressor; truncated arrays from partial reads or wrong length prefixes; corrupt stored rollback data; empty non-null arrays causing 'Not in ZIP format' errors.
Common situations: Compressor type mismatch between seata endpoints; DB storing compressed undo data damaged by charset conversion; middleware mangling binary bodies; version upgrades changing default compressor.
Related errors
AI-assisted analysis of apache/incubator-seata@e01f97c6db (2026-08-14).
Data as JSON: /api/errors/dfcb680476e3f57f.
Report an issue: GitHub.