ZipOutputStream & directories
Eirik Bjørsnøs
eirbjo at gmail.com
Mon Mar 6 20:20:11 UTC 2023
On Mon, Mar 6, 2023 at 8:45 PM Alan Bateman <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,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20230306/738d9734/attachment.htm>
More information about the core-libs-dev
mailing list