RFR: 8369181: InflaterOutputStream: writing after finish() results in IllegalStateException instead of an IOException

Alan Bateman alanb at openjdk.org
Fri Feb 27 10:34:21 UTC 2026


On Thu, 26 Feb 2026 11:28:17 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Can I please get a review of this change which addresses the issue noted in https://bugs.openjdk.org/browse/JDK-8369181?
> 
> As noted in that issue, if `finish()` is called on a `InflaterOutputStream` that was constructed without passing a `Inflater`, then any subsequent `write()`s on that `InflaterOutputStream` result in an `IllegalStateException`, because we close the `Inflater` in `finish()`. The commit in this PR, fixes the issue by throwing the specified `IOException` in place of the `IllegalStateException`. 
> 
> At the same time, the documentation of `finish()` has been enhanced to clarify the current behaviour, through a `@implSpec`.
> 
> Alternative approaches of deprecating finish() and/or not closing the default Inflater were considered, but given the current long standing implementation of finish(), it was decided to merely specify the current behaviour of closing the  default Inflater in finish().
> 
> A new jtreg test has been added to reproduce the issue and verify the fix. tier1, tier2, tier3 testing of this change completed without any related issues.
> 
> I'll file a CSR shortly for this change.

src/java.base/share/classes/java/util/zip/InflaterOutputStream.java line 224:

> 222: 
> 223:     /**
> 224:      * Forces writing any pending buffered decompressed data to the output stream,

What you would think about dropping the term "Force" from this method, and flush. They can simply say that they write any pending buffered decompress data to the underlying output stream.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29935#discussion_r2863651878


More information about the core-libs-dev mailing list