RFR: 8376403: Avoid loading ArrayDeque in java.util.zip.ZipFile [v3]

Jaikiran Pai jpai at openjdk.org
Fri Feb 20 12:30:58 UTC 2026


On Tue, 27 Jan 2026 09:30:19 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:

>> Hot on the heals of #29288, this PR replaces `ArrayDeque` with `ArrayList` for the Inflater cache implementation in `ZipFile.CleanableResource`.
>> 
>> With this PR, we change the order of the cache from a LIFO queue to a FIFO stack backed by ArrayList. The order seems unimportant, and has indeed been FIFO in the past when using `java.util.Vector`. Intuitively, it should be better to return the most recently used Inflater.
>> 
>> No tests updated, strict refactoring, `noreg-cleanup`.
>
> Eirik Bjørsnøs has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove null check of final field istreams which is never null

src/java.base/share/classes/java/util/zip/ZipFile.java line 736:

> 734:                         inf.reset();
> 735:                         inflaters.addLast(inf);
> 736:                         return;

Hello Eirik, nit - my preference here would be to use `add(...)`, which is the same as `addLast(...)` but feels a bit more natural when using a `List`. When reading the code, the presence of `addLast(...)` makes me stop for a while to see if there's anything more going on here other than just adding to a `List`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29430#discussion_r2832973747


More information about the core-libs-dev mailing list