You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stefan Bodewig (JIRA)" <ji...@apache.org> on 2012/06/03 17:16:23 UTC

[jira] [Commented] (COMPRESS-187) ZipArchiveInputStream and ZipFile don't produce equals ZipArchiveEntry instances

    [ https://issues.apache.org/jira/browse/COMPRESS-187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288177#comment-13288177 ] 

Stefan Bodewig commented on COMPRESS-187:
-----------------------------------------

The ZIP structure holds information about entries in two places.  First it contains all entries sequentially with some metadata attached to it and at the end it holds the so called central directory which holds all the metadata - including comments - for all entries.  The central directory is the real authority, any entry not listed there is not really part of the archive.

ZipFile implements parsing ZIP archives correctly, it reads the central directory and from there calculates all necessary data to find the offset of a data entry when it comes to reading an entry.  ZipArchiveInputStream is forced to rely on the subset of metadata that is available with the entires themselves (the so called local file header) - it is supposed to work in streaming mode andcannot wait or the central directory to show up before returning the first result.

I don't think java.util.zip works any different from Commons Compress.  In fact ZipEntry doesn't even override equals so I wouldn't excpect two ZipEntries to ever be the same, strange.

We can change the code in equals to make empty comments and null comments compare to equal.  This may work for your particular case but won't work in general as metadata in local file header and central directory may be different for other fields as well.
                
> ZipArchiveInputStream and ZipFile don't produce equals ZipArchiveEntry instances
> --------------------------------------------------------------------------------
>
>                 Key: COMPRESS-187
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-187
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Archivers
>    Affects Versions: 1.4
>            Reporter: Thomas Mortagne
>
> I'm trying to use a ZipArchiveEntry coming from ZipArchiveInputStream that I stored somwhere for later with a ZipFile and it does not work.
> The reason is that it can't find the ZipArchiveEntry in the ZipFile entries map. It is exactly the same zip file but both entries are not equals so the Map#get fail.
> As far as I can see the main difference is that {{comment}} is null in ZipArchiveInputStream while it's en empty string in ZipFile. I looked at ZipArchiveInputStream and it looks like the comment (whatever it is) is simply not parsed while I can find some code related to the comment at the end of ZIipFile#readCentralDirectoryEntry.
> Note that java.util.zip does not have this issue. Did not checked what they do but the zip entries are equals.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira