8170831: ZipFile implementation no longer caches the last accessed entry/pos
Reviewed-by: psandoz
This commit is contained in:
parent
502274b2c1
commit
d08eb8c2a9
@ -331,7 +331,9 @@ class ZipFile implements ZipConstants, Closeable {
|
|||||||
ZipFileInputStream in = null;
|
ZipFileInputStream in = null;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
ensureOpen();
|
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);
|
pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false);
|
||||||
} else {
|
} else {
|
||||||
pos = zsrc.getEntryPos(zc.getBytes(entry.name), false);
|
pos = zsrc.getEntryPos(zc.getBytes(entry.name), false);
|
||||||
@ -526,6 +528,9 @@ class ZipFile implements ZipConstants, Closeable {
|
|||||||
Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
|
Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String lastEntryName;
|
||||||
|
private int lastEntryPos;
|
||||||
|
|
||||||
/* Checks ensureOpen() before invoke this method */
|
/* Checks ensureOpen() before invoke this method */
|
||||||
private ZipEntry getZipEntry(String name, byte[] bname, int pos) {
|
private ZipEntry getZipEntry(String name, byte[] bname, int pos) {
|
||||||
byte[] cen = zsrc.cen;
|
byte[] cen = zsrc.cen;
|
||||||
@ -563,6 +568,8 @@ class ZipFile implements ZipConstants, Closeable {
|
|||||||
e.comment = zc.toString(cen, start, clen);
|
e.comment = zc.toString(cen, start, clen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lastEntryName = e.name;
|
||||||
|
lastEntryPos = pos;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user