DelegatingStream implements Stream<T> { @Override public boolean anyMatch(Predicate<? super T> predicate) { boolean b = stream.anyMatch(predicate); close(); return b; } DelegatingStream(Stream<T> stream); @Override Stream<T> filter(Predicate<? super T> predicate); @Override Stream<R> map(Function<? super T, ? extends R> mapper); @Override IntStream mapToInt(ToIntFunction<? super T> mapper); @Override LongStream mapToLong(ToLongFunction<? super T> mapper); @Override DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper); @Override Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper); @Override IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper); @Override LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper); @Override DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper); @Override Stream<T> distinct(); @Override Stream<T> sorted(); @Override Stream<T> sorted(Comparator<? super T> comparator); @Override Stream<T> peek(Consumer<? super T> action); @Override Stream<T> limit(long maxSize); @Override Stream<T> skip(long n); @Override void forEach(Consumer<? super T> action); @Override void forEachOrdered(Consumer<? super T> action); @Override Object[] toArray(); @Override A[] toArray(IntFunction<A[]> generator); @Override T reduce(T identity, BinaryOperator<T> accumulator); @Override Optional<T> reduce(BinaryOperator<T> accumulator); @Override U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner); @Override R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner); @Override R collect(Collector<? super T, A, R> collector); @Override Optional<T> min(Comparator<? super T> comparator); @Override Optional<T> max(Comparator<? super T> comparator); @Override long count(); @Override boolean anyMatch(Predicate<? super T> predicate); @Override boolean allMatch(Predicate<? super T> predicate); @Override boolean noneMatch(Predicate<? super T> predicate); @Override Optional<T> findFirst(); @Override Optional<T> findAny(); @Override Iterator<T> iterator(); @Override Spliterator<T> spliterator(); @Override boolean isParallel(); @Override Stream<T> sequential(); @Override Stream<T> parallel(); @Override Stream<T> unordered(); @Override Stream<T> onClose(Runnable closeHandler); @Override void close();  }
@Test public void testAnyMatch() { assertTerminalOpCallsClose(stream -> stream.anyMatch(s -> true)); }