RFR: 8378759: Make ZipFile.CleanableResource.inflaterCache field final
Eirik Bjørsnøs
eirbjo at openjdk.org
Thu Feb 26 12:37:54 UTC 2026
Please review this cleanup PR where we simplify synchronization on ZipFile's inflater cache.
Currently, the `ZipFile.CleanableResource.inflaterCache` field is non-final, is used in synchronization and is set to `null` to indicate a closed inflater cache. This complicates the state considerations for synchronization, requiring double-checking that the cache does not close under us. Generally, correctness of synchronizing on a non-final field which can also be null is hard to reason about.
This PR marks the `inflaterCache` field as `final` and introduces a boolean flag field to model the closed state explicitly. This allows synchronization to be simplified, double-checking to be removed and the closed state to be more obvious. If we want the future ZipFile to be less mutable, this is one step in that direction.
Cleanup refactoring, `noreg-cleanup`
-------------
Commit messages:
- Clear inflaterCache before closing
- Make inflaterCache field final and closed state explicit
Changes: https://git.openjdk.org/jdk/pull/29937/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29937&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8378759
Stats: 27 lines in 1 file changed: 5 ins; 11 del; 11 mod
Patch: https://git.openjdk.org/jdk/pull/29937.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29937/head:pull/29937
PR: https://git.openjdk.org/jdk/pull/29937
More information about the core-libs-dev
mailing list