RFR: 8225763: Inflater and Deflater should implement AutoCloseable [v5]

Jaikiran Pai jpai at openjdk.org
Fri Nov 15 11:15:30 UTC 2024


On Thu, 14 Nov 2024 17:33:34 GMT, Lance Andersen <lancea at openjdk.org> wrote:

>> 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 10 additional commits since the last revision:
>> 
>>  - merge latest from master branch
>>  - update tests to match the new specification
>>  - Stuart's review - update the close() and end() expectations
>>  - Stuart's review - improve class level javadoc
>>  - merge latest from master branch
>>  - merge latest from master branch
>>  - Chen's suggestion - improve code comment
>>  - convert the tests to junit
>>  - fix whitespace
>>  - 8225763: Inflater and Deflater should implement AutoCloseable
>
> src/java.base/share/classes/java/util/zip/Deflater.java line 878:
> 
>> 876:      * If this method is invoked multiple times, the subsequent calls are treated as a no-op.
>> 877:      * Several other methods defined by this class will throw an {@link IllegalStateException}
>> 878:      * if invoked on a closed {@code Deflater}.
> 
> All of the methods which call ensureOpen should either document that an IllegalStateException may be thrown or you could add it to the header of the class.

Hello Lance, you are right - I forgot to do that when I changed it to throw IllegalStateException from the previous NullPointerException. I've now updated the PR to document this on individual methods in the Inflater/Deflater which throw this exception.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19675#discussion_r1843607156


More information about the core-libs-dev mailing list