46 lines
1.7 KiB
Diff
46 lines
1.7 KiB
Diff
|
|
From 8e3e20eef3f18d023ffc327a9fae30c34de84773 Mon Sep 17 00:00:00 2001
|
||
|
|
Date: Thu, 21 Sep 2023 15:24:45 +0800
|
||
|
|
Subject: add 8170831-ZipFile-implementation-no-longer-caches-the
|
||
|
|
|
||
|
|
---
|
||
|
|
jdk/src/share/classes/java/util/zip/ZipFile.java | 9 ++++++++-
|
||
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/jdk/src/share/classes/java/util/zip/ZipFile.java b/jdk/src/share/classes/java/util/zip/ZipFile.java
|
||
|
|
index b6a6c2a48..38b642bdc 100644
|
||
|
|
--- a/jdk/src/share/classes/java/util/zip/ZipFile.java
|
||
|
|
+++ b/jdk/src/share/classes/java/util/zip/ZipFile.java
|
||
|
|
@@ -342,7 +342,9 @@ class ZipFile implements ZipConstants, Closeable {
|
||
|
|
ZipFileInputStream in = null;
|
||
|
|
synchronized (this) {
|
||
|
|
ensureOpen();
|
||
|
|
- if (!zc.isUTF8() && (entry.flag & EFS) != 0) {
|
||
|
|
+ if (Objects.equals(lastEntryName, entry.name)) {
|
||
|
|
+ pos = lastEntryPos;
|
||
|
|
+ } else if (!zc.isUTF8() && (entry.flag & EFS) != 0) {
|
||
|
|
pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false);
|
||
|
|
} else {
|
||
|
|
pos = zsrc.getEntryPos(zc.getBytes(entry.name), false);
|
||
|
|
@@ -533,6 +535,9 @@ class ZipFile implements ZipConstants, Closeable {
|
||
|
|
Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
|
||
|
|
}
|
||
|
|
|
||
|
|
+ private String lastEntryName;
|
||
|
|
+ private int lastEntryPos;
|
||
|
|
+
|
||
|
|
/* Checks ensureOpen() before invoke this method */
|
||
|
|
private ZipEntry getZipEntry(String name, int pos) {
|
||
|
|
byte[] cen = zsrc.cen;
|
||
|
|
@@ -566,6 +571,8 @@ class ZipFile implements ZipConstants, Closeable {
|
||
|
|
e.comment = zc.toString(cen, start, clen);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
+ lastEntryName = e.name;
|
||
|
|
+ lastEntryPos = pos;
|
||
|
|
return e;
|
||
|
|
}
|
||
|
|
|
||
|
|
--
|
||
|
|
2.22.0
|
||
|
|
|