commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject [compress] ZipFile and Duplicate Entries
Date Mon, 20 May 2013 15:48:18 GMT

over in Ant land a bug was raised that points at a problem in ZipFile
(Commons Compress' zip package is a fork of Ant's code and I try to keep
them in sync).

When an archive contains duplicate entries - which is totally valid in
ZIPs - ZipFile's getEntry can sometimes return ZipArchiveEntry instances
that will receive null for ZipFile's getInputStream.  This is
COMPRESS-227 which contains the details of the problem.

I've for now fixed it in trunk by ignoring all but the last entry od the
same name seen while parsing the central directory.  I've chosen to pick
the last since this is what ZipFile used to do for duplicate entries
without extra fields anyway.

There may be reasons to return only the first entry and there may even
be reasons to provide a different method that returned all entries of a
given name, something like

     List<ZipArchiveEntry> getEntries(String name)

The later would require some more book-keeping but I don't think the
performance impact would be too big.

Tools like InfoZIP's zip/unzip list all entries of a given name.

Do you think it is worth it?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message