RFR: 8193682: Infinite loop in ZipOutputStream.close() [v3]

Sean Coffey coffeys at openjdk.java.net
Tue Oct 12 15:42:52 UTC 2021


On Tue, 12 Oct 2021 14:46:33 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/zip/DeflaterOutputStream.java line 256:
>> 
>>> 254:             } catch (Exception e) {
>>> 255:                 def.end();
>>> 256:                 out.close();
>> 
>> out.close not needed with try with resources.
>
> This changes deflate to close the compressor and the output stream when there is an I/O exception. I expect this will need a spec change or a re-examination of the issue to see if there are alternatives.

the out.close() call could be removed I guess. Leave it for user code to handle etc. Safer for spec also.

Main goal is to break the looping of the deflate call. The usesDefaultDeflater boolean might be useful in helping determine if def.end() should be called or not. If that boolean is false, then maybe we could just alter the input buffer by setting it to a size 0 buffer (ZipUtils.defaultBuf) -- worth a look.

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

PR: https://git.openjdk.java.net/jdk/pull/5522


More information about the core-libs-dev mailing list