diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java index d06557a4d0..e25aa33140 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java @@ -79,6 +79,13 @@ public interface Archive extends Iterable, AutoCloseable { throw new IllegalStateException("Unexpected call to getNestedArchives(filter)"); } + /** + * Return a new iterator for the archive entries. + * @see java.lang.Iterable#iterator() + * @deprecated since 2.3.0 in favor of using + * {@link org.springframework.boot.loader.jar.JarFile} to access entries and + * {@link #getNestedArchives(EntryFilter, EntryFilter)} for accessing nested archives. + */ @Deprecated @Override Iterator iterator(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/JarFileArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/JarFileArchiveTests.java index 3cc4d24b40..41801217a1 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/JarFileArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/JarFileArchiveTests.java @@ -36,6 +36,7 @@ import org.junit.jupiter.api.io.TempDir; import org.springframework.boot.loader.TestJarCreator; import org.springframework.boot.loader.archive.Archive.Entry; +import org.springframework.boot.loader.jar.JarFile; import org.springframework.util.FileCopyUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -171,13 +172,13 @@ class JarFileArchiveTests { output.write(zip64JarData); output.closeEntry(); } - try (JarFileArchive jarFileArchive = new JarFileArchive(file); - Archive nestedArchive = jarFileArchive - .getNestedArchive(getEntriesMap(jarFileArchive).get("nested/zip64.jar"))) { - Iterator it = nestedArchive.iterator(); + try (JarFile jarFile = new JarFile(file)) { + ZipEntry nestedEntry = jarFile.getEntry("nested/zip64.jar"); + JarFile nestedJarFile = jarFile.getNestedJarFile(nestedEntry); + Iterator iterator = nestedJarFile.iterator(); for (int i = 0; i < 65537; i++) { - assertThat(it.hasNext()).as(i + "nth file is present").isTrue(); - it.next(); + assertThat(iterator.hasNext()).as(i + "nth file is present").isTrue(); + iterator.next(); } } }