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

Jaikiran Pai jpai at openjdk.org
Mon Mar 2 05:20:16 UTC 2026


> 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.

Jaikiran Pai has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:

 - Alan's review - adjust the doc for flush() and finish() methods
 - remove extra space
 - merge latest from master branch
 - 8369181 (v1): InflaterOutputStream: writing after finish() results in a NullPointerException (NPE) instead of an IOException

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/29935/files
  - new: https://git.openjdk.org/jdk/pull/29935/files/849708be..60419594

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29935&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29935&range=00-01

  Stats: 6731 lines in 206 files changed: 3883 ins; 1459 del; 1389 mod
  Patch: https://git.openjdk.org/jdk/pull/29935.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29935/head:pull/29935

PR: https://git.openjdk.org/jdk/pull/29935


More information about the core-libs-dev mailing list