apache/shenyu · error · IllegalArgumentException
total size exceeds maximum allowed value.
Error message
total size exceeds maximum allowed value.
What it means
ZipUtil.unzip throws this IllegalArgumentException when the cumulative uncompressed size of all processed entries exceeds maxTotalSize. This is the archive-level counterpart of the per-entry limit, preventing total memory exhaustion from many moderately sized entries.
Solutions
- Shrink the archive (remove redundant files, use higher compression) before uploading.
- Increase maxTotalSize if legitimate bundles need more room.
- Inspect the archive's total uncompressed size with `unzip -l` before uploading.
Example fix
// before ZipUtil.unzip(in, maxEntries, maxEntrySize, 10_000_000L); // 10MB total // after ZipUtil.unzip(in, maxEntries, maxEntrySize, 50_000_000L); // 50MB total
Defensive patterns
Strategy: validation
Validate before calling
try (ZipFile zf = new ZipFile(zipFile)) {
long total = zf.stream().filter(e -> !e.isDirectory())
.mapToLong(ZipEntry::getSize).sum();
if (total > maxTotalSize) {
throw new IllegalArgumentException("total " + total + " exceeds limit " + maxTotalSize);
}
} Try / catch
try {
ZipUtil.unzip(in, maxEntryCount, maxEntrySize, maxTotalSize);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("total size exceeds")) {
log.error("Archive expands beyond total size budget");
}
} Prevention
- Compare the archive's total uncompressed size (unzip -l) against the limit first.
- Trim bundles to only the files the gateway needs.
- Reject suspicious archives (tiny compressed, huge uncompressed) at upload time.
When it happens
Trigger: Unzipping an archive whose entries together decompress beyond maxTotalSize, even if each entry individually stays under maxEntrySize.
Common situations: Uploading large config/plugin bundles; zip-bomb archives designed to expand massively.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- entry size exceeds maximum allowed value.
- entry count exceeds maximum of " + maxEntryCount
- Access to localhost is not allowed
- Access to private or internal IP addresses is not allowed
- Access to sensitive ports is not allowed
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/9ba59ff7739d38af.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/ZipUtil.java:124
if (entry.isDirectory()) {
continue;
}
entryCount++;
if (entryCount > maxEntryCount) {
throw new IllegalArgumentException("entry count exceeds maximum of " + maxEntryCount);
}
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
byte[] buffer = new byte[1024];
int offset;
long entrySize = 0L;
while ((offset = zipIn.read(buffer)) != -1) {
entrySize += offset;
totalSize += offset;
if (entrySize > maxEntrySize) {
throw new IllegalArgumentException("entry size exceeds maximum allowed value.");
}
if (totalSize > maxTotalSize) {
throw new IllegalArgumentException("total size exceeds maximum allowed value.");
}
out.write(buffer, 0, offset);
}
String entryName = entry.getName();
itemList.add(new ZipItem(entryName, out.toString(StandardCharsets.UTF_8)));
} catch (IOException e) {
LOG.error("unzip error", e);
}
}
} catch (IOException e) {
LOG.error("unzip error", e);
}
return new UnZipResult(itemList);
}
public static class ZipItem {
private final String itemName;View on GitHub (pinned to 567142e072)