RFR: 8278165: Clarify that ZipInputStream does not access the CEN fields for a ZipEntry [v4]

Alan Bateman alanb at openjdk.org
Wed Sep 14 12:45:30 UTC 2022


On Tue, 13 Sep 2022 21:13:15 GMT, Lance Andersen <lancea at openjdk.org> wrote:

>> Hi,
>> 
>> Please review this update to the ZipInputStream class description to clarify that ZipInputStream walks sequentially through each Zip Entry contained within the Zip File.  As a result, the CEN header for the Zip file entries are not read resulting in ZipInputStream not having access to information that is stored within the CEN Header fields such the as the external file attributes which can be used to store optional data such as Posix Permissions.
>
> Lance Andersen has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove stray comma after ZipFile

src/java.base/share/classes/java/util/zip/ZipInputStream.java line 55:

> 53:  *    {@snippet :
> 54:  *      try (FileInputStream fis = new FileInputStream(jar.toFile());
> 55:  *           ZipInputStream zis = new ZipInputStream(fis)) {

One other comment on the snippet is that the type of "jar" may not be obvious to readers. I think you'll need Path jar = ...  in which case changing it Files.newInputStream(jar) might be simpler.

src/java.base/share/classes/java/util/zip/ZipInputStream.java line 68:

> 66:  * will not have access to its metadata such as the external file attributes.
> 67:  * {@linkplain ZipFile} may be used when the information stored within
> 68:  * the CEN header is required.

I wonder if this paragraph should be an apiNote. It's not wrong as is but it feels like a note to remind developers that this is an "input stream" for iterating through the ZIP entries. The external files attributes are in the CEN at the end of the ZIP file so this is why they aren't available.

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

PR: https://git.openjdk.org/jdk/pull/10102


More information about the core-libs-dev mailing list