From 4138e59c33549e15b5d2d4de33c18ece13890fb0 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 14 Sep 2020 13:48:59 -0700 Subject: [PATCH] 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 --- .../org/springframework/boot/loader/jar/JarFileEntries.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java index 5645abdd36..af8b3967af 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java @@ -370,7 +370,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable { 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; }