From b71bab2817a28d64a152395465b82d4e55e2865b Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 8 Jun 2020 12:08:33 -0700 Subject: [PATCH] Document deprecations of Archive.iterator() Closes gh-21695 --- .../boot/loader/archive/Archive.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) 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 fff6b634651..e3dd20ee7fa 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 @@ -21,6 +21,10 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; import java.util.List; +import java.util.Objects; +import java.util.Spliterator; +import java.util.Spliterators; +import java.util.function.Consumer; import java.util.jar.Manifest; import org.springframework.boot.loader.Launcher; @@ -90,6 +94,36 @@ public interface Archive extends Iterable, AutoCloseable { @Override Iterator iterator(); + /** + * Performs the given action for each element of the {@code Iterable} until all + * elements have been processed or the action throws an exception. + * @see Iterable#forEach + * @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 + default void forEach(Consumer action) { + Objects.requireNonNull(action); + for (Entry entry : this) { + action.accept(entry); + } + } + + /** + * Creates a {@link Spliterator} over the elements described by this {@code Iterable}. + * @see Iterable#spliterator + * @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 + default Spliterator spliterator() { + return Spliterators.spliteratorUnknownSize(iterator(), 0); + } + /** * Return if the archive is exploded (already unpacked). * @return if the archive is exploded