RFR JDK-6233323: ZipEntry.isDirectory() may return false incorrectly
Roger Riggs
Roger.Riggs at Oracle.com
Tue Jun 28 21:15:49 UTC 2016
Looks fine,
Roger
On 6/28/2016 4:58 PM, Xueming Shen wrote:
> Hi,
>
> Please help codereview the change for JDK-6233323/8144977
>
> issue:
> https://bugs.openjdk.java.net/browse/JDK-6233323
> https://bugs.openjdk.java.net/browse/JDK-8144977
>
> webrev: http://cr.openjdk.java.net/~sherman/62333233_8144977/webrev
>
> This is an implementation issue from day-one. ZIP spec specifies the
> name of a directory entry must be ended with a slash, so a directory
> name "dir" in ZIP world should have the name "dir/".
>
> ZipFile.getEntry() works well with these type of "canonicalized"
> directory
> names. However, its implementation also tries to be "liberal" when
> taking name that doesn't end with "/". Where there is no such entry
> (file)
> found, it tries a second lookup with a "/" appended, and returns such
> entry
> if find one. The original implementation always to use the original
> passed
> in name (the one without the ending slash) as the entry name for the
> returned ZipEntry. This is fine if the entry is from the first round
> of lookup,
> in which the name stored in zip file matches the passed in name and to
> use the name directly obviously helps avoiding creating another String
> object from the binary name (byte[] in zip entry). But in case of the
> entry
> is from the second round lookup, the direct consequence is the
> isDirectory()
> method of the returned entry always returns false (ZipEntry.isDirectory()
> implementation simply checks if the name ends with / or not), even it is
> actually a directory entry.
>
> The fix is to simply return the name stored in the zip file. It
> appears this
> should be the desired and expected result.
>
> Thanks,
> Sherman
>
More information about the core-libs-dev
mailing list