Should Inflater & Deflater implement Closeable?

some-java-user-99206970363698485155 at vodafonemail.de some-java-user-99206970363698485155 at vodafonemail.de
Tue Nov 15 23:18:19 UTC 2022


Hello,
java.util.zip.Inflater and java.util.zip.Deflater both have an `end()` method to release native memory. However, both classes
do not implement Closeable. This might prevent IDEs and other tooling from indicating that users should release the
resources, and prevents usage in try-with-resources.

Are the reasons for this only historical? (Inflater and Deflater seem to be older than Closeable)
If so, would it be reasonable to adjust these classes to implement Closeable? The implementation could then delegate to
`end()` (and omit `throws IOException`), though to satisfy the `close()` contract it might be necessary to track whether the
method has already been before.

I did not find anything regarding this on the bug tracker or this mailing list.

Kind regards



More information about the core-libs-dev mailing list