RFR: 8378759: Make ZipFile.CleanableResource.inflaterCache field final [v2]

Eirik Bjørsnøs eirbjo at openjdk.org
Thu Feb 26 16:00:19 UTC 2026


On Thu, 26 Feb 2026 15:40:59 GMT, Chen Liang <liach at openjdk.org> wrote:

> Old code ensured getInflater can fail properly when inflaterCache is null. This safety is lost in your refactor.

getInflater is only called from ZipFile::getInputStream which always holds a lock on the ZipFile instance while calling getInflater.

CleanableResource::run can either be run from a Cleaner, in which case nothing references the ZipFile and thus cannot call getInflater. Or it can be run via ZipFile::close, which always holds a lock on the ZipFile instance.

getInputStream will never call getInflater in the case where the inflaterCache is null, since ensureOpen and CleanableResource:run are run holding the same lock.

Even if it could, "fail properly" is a stretch. It would fail with an undocumented NPE, right?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/29937#issuecomment-3967528684


More information about the core-libs-dev mailing list