ZipOutputStream & directories

Lance Andersen lance.andersen at oracle.com
Mon Mar 6 20:32:56 UTC 2023


Adding an API Note will require a CSR.

And yes,  what we often think as the right change tends to bite us (given this code has been in the wild since the 90s) so best to err on the side of documentation vs. assuming this change would not cause more problems than it is worth.

Best
Lance

On Mar 6, 2023, at 3:20 PM, Eirik Bjørsnøs <eirbjo at gmail.com<mailto:eirbjo at gmail.com>> wrote:

On Mon, Mar 6, 2023 at 8:45 PM Alan Bateman <Alan.Bateman at oracle.com<mailto:Alan.Bateman at oracle.com>> wrote:
Changing ZOS.putNextEntry to ignore the method/size provided by the
caller would change long standing behavior, and Hyrum's Law has it that
somebody will notice.

I was not thinking of changing anything if the caller actually specified a method. This would be just for the default/unspecified case, in which case ZipEntry.method is -1.

So:

if (e.method == -1) {

    if (e.isDirectory()) {
       // New code:
       e.setMethod(STORED);
       e.setSize(0);
       e.setCrc(0);
    } else {
        // Today's code:
        e.method = method;  // use default method
    }
}

But I guess this doesn't completely alleviate concerns, since there might be code out there doing:

zo.putNextEntry("directory/");
zo.write("Hello".getBytes());

(This would be very weird code, but people might have found it convenient to attach data to directories somehow).

This may be something for an API note rather than
an implementation change.

Am I right that this would not be a specification change, so it would not require a CSR?

Thanks,


[cid:E1C4E2F0-ECD0-4C9D-ADB4-B16CA7BCB7FC at home]






Lance Andersen | Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
Lance.Andersen at oracle.com<mailto:Lance.Andersen at oracle.com>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20230306/9ddb3419/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: oracle_sig_logo.gif
Type: image/gif
Size: 658 bytes
Desc: oracle_sig_logo.gif
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20230306/9ddb3419/oracle_sig_logo-0001.gif>


More information about the core-libs-dev mailing list