Fix potential JarFileEntries ClassCastException

Update `JarFileEntries` so that the interface is obtained rather than
the concrete implementation. This allows `JarEntry` values to be used
without causing a ClassCastException.

Closes gh-19041
2.1.x
Phillip Webb 4 years ago
parent 492e1a4c0f
commit 4138e59c33

@ -370,7 +370,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
int hashCode = AsciiBytes.hashCode(name);
int index = getFirstIndex(hashCode);
while (index >= 0 && index < this.size && this.hashCodes[index] == hashCode) {
CentralDirectoryFileHeader candidate = getEntry(index, CentralDirectoryFileHeader.class, false, null);
FileHeader candidate = getEntry(index, FileHeader.class, false, null);
if (candidate.hasName(name, NO_SUFFIX)) {
return index;
}

Loading…
Cancel
Save