-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8340814: ZipFileInflaterInputStream should release its Inflater after observing EOF #21157
base: master
Are you sure you want to change the base?
Conversation
… observing that the stream is fully consumed (EOF)
👋 Welcome back eirbjo! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@eirbjo This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Please consider this PR which makes
ZipFileInflaterInputStream
release itsInflater
instance back to the pool when observing that the stream has been fully consumed.This is motivated by the following observations:
ZipFileInflaterInputStream
has reached the end of stream, itsInflater
instance no longer does useful work.ZipFile::getInputStream
without properly closing it is probably common. Obtaining it without fully consuming it is probably more rare. (Something likeclassLoader.getInputStream(entry).readAllBytes()
is probably common)Inflater
when theCleaner
closes the stream, this will only happen at some later point in time. In the meantime,ZipFile::getInputStream
may produce many newInflater
instances. These will all be released to the pool once GC eventually catches up.Inflater
is released to to pool, it will stay there for the lifetime of theZipFile
ZipFile
may often be as long as the application (consider class loaders).This PR suggests the following changes:
ZipFileInflaterInputStream.eof
tocompressedEof
. (This tracks the EOF of the filtered input stream)ZipFileInflaterInputStream.eof
to track the EOF of uncompressed data.ZipFileInflaterInputStream.read(byte[] b, int off, int len)
to detect the EOF of uncompressed data and release theInflater
instance back to the pool when it is no longer needed.Inflater
instance from being used after being released and reset, the following updates are needed:ZipFileInflaterInputStream.read
must check if EOF has been reached but that the stream has not yet been closed. In this case, EOF should be returned.ZipFileInflaterInputStream.available
needs an update to return 0 if EOF has been detected.The PR adds a test
ReleaseInflaterOnEOF
which verifies that all fully consumed input streams are backed by the sameInflater
instance.This PR was inspired by JDK-7031076 and this discussion: https://mail.openjdk.org/pipermail/core-libs-dev/2011-March/006341.html
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21157/head:pull/21157
$ git checkout pull/21157
Update a local copy of the PR:
$ git checkout pull/21157
$ git pull https://git.openjdk.org/jdk.git pull/21157/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21157
View PR using the GUI difftool:
$ git pr show -t 21157
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21157.diff
Webrev
Link to Webrev Comment