Skip to content

Commit

Permalink
Remove RejectecExecution legacy handler leftovers (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Sep 15, 2024
1 parent ad8fff7 commit f380fa1
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/test/java/com/pivovarit/collectors/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -178,7 +177,6 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> tests(Collect
shouldHandleThrowable(collector, name),
shouldShortCircuitOnException(collector, name),
shouldInterruptOnException(collector, name),
shouldHandleRejectedExecutionException(collector, name),
shouldRemainConsistent(collector, name)
);

Expand All @@ -204,7 +202,6 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> streamingTest
shouldPushElementsToStreamAsSoonAsPossible(collector, name),
shouldHandleThrowable(collector, name),
shouldShortCircuitOnException(collector, name),
shouldHandleRejectedExecutionException(collector, name),
shouldRemainConsistent(collector, name),
shouldRejectInvalidParallelism(collector, name)
);
Expand Down Expand Up @@ -315,23 +312,6 @@ private static <R extends Collection<Integer>> DynamicTest shouldHandleThrowable
});
}

private static <R extends Collection<Integer>> DynamicTest shouldHandleRejectedExecutionException(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name) {
return dynamicTest(format("%s: should propagate rejected execution exception", name), () -> {
Executor executor = command -> {throw new RejectedExecutionException();};
List<Integer> elements = IntStream.range(0, 1000).boxed().toList();

assertThatThrownBy(() -> elements.stream()
.collect(collector.apply(i -> returnWithDelay(i, ofMillis(10000)), executor, PARALLELISM))
.join())
.isInstanceOfAny(RejectedExecutionException.class, CompletionException.class)
.matches(ex -> {
if (ex instanceof CompletionException) {
return ex.getCause() instanceof RejectedExecutionException;
} else return true;
});
});
}

private static <R extends Collection<Integer>> DynamicTest shouldRemainConsistent(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name) {
return dynamicTest(format("%s: should remain consistent", name), () -> {
int parallelism = 100;
Expand Down

0 comments on commit f380fa1

Please sign in to comment.