Skip to content

Commit 93d9147

Browse files
committed
Add deprecation documentation to Archive.iterator
See gh-16655
1 parent 1e117c7 commit 93d9147

File tree

2 files changed

+14
-6
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-loader/src

2 files changed

+14
-6
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ default List<Archive> getNestedArchives(EntryFilter filter) throws IOException {
7979
throw new IllegalStateException("Unexpected call to getNestedArchives(filter)");
8080
}
8181

82+
/**
83+
* Return a new iterator for the archive entries.
84+
* @see java.lang.Iterable#iterator()
85+
* @deprecated since 2.3.0 in favor of using
86+
* {@link org.springframework.boot.loader.jar.JarFile} to access entries and
87+
* {@link #getNestedArchives(EntryFilter, EntryFilter)} for accessing nested archives.
88+
*/
8289
@Deprecated
8390
@Override
8491
Iterator<Entry> iterator();

spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/JarFileArchiveTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import org.springframework.boot.loader.TestJarCreator;
3838
import org.springframework.boot.loader.archive.Archive.Entry;
39+
import org.springframework.boot.loader.jar.JarFile;
3940
import org.springframework.util.FileCopyUtils;
4041

4142
import static org.assertj.core.api.Assertions.assertThat;
@@ -171,13 +172,13 @@ void nestedZip64ArchivesAreHandledGracefully() throws Exception {
171172
output.write(zip64JarData);
172173
output.closeEntry();
173174
}
174-
try (JarFileArchive jarFileArchive = new JarFileArchive(file);
175-
Archive nestedArchive = jarFileArchive
176-
.getNestedArchive(getEntriesMap(jarFileArchive).get("nested/zip64.jar"))) {
177-
Iterator<Entry> it = nestedArchive.iterator();
175+
try (JarFile jarFile = new JarFile(file)) {
176+
ZipEntry nestedEntry = jarFile.getEntry("nested/zip64.jar");
177+
JarFile nestedJarFile = jarFile.getNestedJarFile(nestedEntry);
178+
Iterator<JarEntry> iterator = nestedJarFile.iterator();
178179
for (int i = 0; i < 65537; i++) {
179-
assertThat(it.hasNext()).as(i + "nth file is present").isTrue();
180-
it.next();
180+
assertThat(iterator.hasNext()).as(i + "nth file is present").isTrue();
181+
iterator.next();
181182
}
182183
}
183184
}

0 commit comments

Comments
 (0)