Repository navigation
Conversation
AbstractArchiveBuilder.setMaxEntries(int) caps the number of entries a reader accepts, next to setMaxEntryNameLength(int). ZipFile and TarFile load every entry when opened and SevenZFile sizes its entry table from the header, so a caller cannot apply this limit on their own before the memory is spent. Streaming readers enforce the same limit in getNextEntry(), keeping the option uniform across all formats. The default is Integer.MAX_VALUE, so existing behavior is unchanged.
samiusss
force-pushed
the
max-entries
branch
from
November 16, 2026 14:47
1edecb5 to
c9d9293
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
AbstractArchiveBuilder.setMaxEntries(int), next tosetMaxEntryNameLength(int), so callers can cap how many entries a reader accepts.Why in the library:
ZipFileandTarFileload every entry when they are opened, andSevenZFilesizes its entry table from the header. A caller cannot count entries before that memory is spent, so wrapping the input in aBoundedInputStreamdoes not help here. Streaming readers enforce the same limit ingetNextEntry(), so the option behaves the same across all formats.How:
ZipFileandTarFilecheck while collecting entries;SevenZFilechecks the declared file count before building its table.ArchiveInputStream.countEntry(E).ArchiveUtils.checkEntryCount(long, int)and throw anArchiveException.Integer.MAX_VALUE, so existing behavior is unchanged. Non-positive values are rejected, likesetMaxEntryNameLength.MaxEntriesTestcovers every reader: a limit equal to the entry count reads the whole archive, one less fails on the last entry.Related to COMPRESS-726, which caps the decompressed size of compressor streams; this is the archive-level counterpart.
mvn; that'smvnon the command line by itself.