commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <>
Subject [jira] [Commented] (COMPRESS-187) ZipArchiveInputStream and ZipFile don't produce equals ZipArchiveEntry instances
Date Sun, 03 Jun 2012 15:16:23 GMT


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

I don't think 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:
>             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 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:!default.jspa
For more information on JIRA, see:


View raw message