Merge branch '3.2.x' into 3.3.x

This commit is contained in:
Andy Wilkinson
2024-08-22 13:07:24 +01:00
10 changed files with 340 additions and 45 deletions

View File

@@ -412,6 +412,25 @@ class NestedJarFileTests {
assertThat(nested).isEqualTo(jdk);
}
@Test
void mismatchedStreamEntriesThrowsException() throws IOException {
File mismatchJar = new File("src/test/resources/jars/mismatch.jar");
IllegalStateException failure = null;
try (NestedJarFile innerJar = new NestedJarFile(mismatchJar, "inner.jar")) {
Enumeration<JarEntry> entries = innerJar.entries();
while (entries.hasMoreElements()) {
try {
entries.nextElement().getCodeSigners();
}
catch (IllegalStateException ex) {
failure = (failure != null) ? failure : ex;
}
}
}
assertThat(failure)
.hasMessage("Content mismatch when reading security info for entry 'content' (content check)");
}
private List<String> collectComments(JarFile jarFile) throws IOException {
try (jarFile) {
List<String> comments = new ArrayList<>();