COMPRESS-466 fill nameMap outside of the loop parsing LFHs
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/cfec5672 Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/cfec5672 Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/cfec5672 Branch: refs/heads/master Commit: cfec567237c7300d0335f8ec5358e5dbfbbcdf00 Parents: a8fc27c Author: Stefan Bodewig <[email protected]> Authored: Sun Oct 7 17:32:33 2018 +0200 Committer: Stefan Bodewig <[email protected]> Committed: Sun Oct 7 17:32:33 2018 +0200 ---------------------------------------------------------------------- .../org/apache/commons/compress/archivers/zip/ZipFile.java | 7 +++++++ 1 file changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-compress/blob/cfec5672/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java index 4b3c8b3..08ffc85 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java @@ -295,6 +295,7 @@ public class ZipFile implements Closeable { final Map<ZipArchiveEntry, NameAndComment> entriesWithoutUTF8Flag = populateFromCentralDirectory(); resolveLocalFileHeaderData(entriesWithoutUTF8Flag); + fillNameMap(); success = true; } finally { closed = !success; @@ -1064,7 +1065,13 @@ public class ZipFile implements Closeable { ZipUtil.setNameAndCommentFromExtraFields(ze, nc.name, nc.comment); } + } + } + private void fillNameMap() { + for (final ZipArchiveEntry ze : entries) { + // entries is filled in populateFromCentralDirectory and + // never modified final String name = ze.getName(); LinkedList<ZipArchiveEntry> entriesOfThatName = nameMap.get(name); if (entriesOfThatName == null) {
