8
8
import java .time .Duration ;
9
9
import java .time .LocalTime ;
10
10
import java .util .Collection ;
11
- import java .util .HashSet ;
12
11
import java .util .LinkedList ;
13
12
import java .util .List ;
14
13
import java .util .Set ;
17
16
import java .util .concurrent .ConcurrentSkipListSet ;
18
17
import java .util .concurrent .CountDownLatch ;
19
18
import java .util .concurrent .Executor ;
20
- import java .util .concurrent .ExecutorService ;
21
19
import java .util .concurrent .Executors ;
22
20
import java .util .concurrent .LinkedBlockingQueue ;
23
21
import java .util .concurrent .ThreadPoolExecutor ;
@@ -165,17 +163,15 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> virtualThread
165
163
return of (
166
164
shouldStartConsumingImmediately (collector , name ),
167
165
shouldShortCircuitOnException (collector , name ),
168
- shouldInterruptOnException (collector , name ),
169
- shouldRemainConsistent (collector , name )
166
+ shouldInterruptOnException (collector , name )
170
167
);
171
168
}
172
169
173
170
private static <R extends Collection <Integer >> Stream <DynamicTest > tests (CollectorSupplier <Function <Integer , Integer >, Executor , Integer , Collector <Integer , ?, CompletableFuture <R >>> collector , String name , boolean limitedParallelism ) {
174
171
var tests = of (
175
172
shouldStartConsumingImmediately (collector , name ),
176
173
shouldShortCircuitOnException (collector , name ),
177
- shouldInterruptOnException (collector , name ),
178
- shouldRemainConsistent (collector , name )
174
+ shouldInterruptOnException (collector , name )
179
175
);
180
176
181
177
tests = limitedParallelism ? of (shouldRespectParallelism (collector , name )) : tests ;
@@ -187,8 +183,7 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> tests(Collect
187
183
private static <R extends Collection <Integer >> Stream <DynamicTest > virtualThreadsStreamingTests (CollectorSupplier <Function <Integer , Integer >, Executor , Integer , Collector <Integer , ?, CompletableFuture <R >>> collector , String name ) {
188
184
return of (
189
185
shouldStartConsumingImmediately (collector , name ),
190
- shouldShortCircuitOnException (collector , name ),
191
- shouldRemainConsistent (collector , name )
186
+ shouldShortCircuitOnException (collector , name )
192
187
);
193
188
}
194
189
@@ -198,7 +193,6 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> streamingTest
198
193
shouldRespectParallelism (collector , name ),
199
194
shouldPushElementsToStreamAsSoonAsPossible (collector , name ),
200
195
shouldShortCircuitOnException (collector , name ),
201
- shouldRemainConsistent (collector , name ),
202
196
shouldRejectInvalidParallelism (collector , name )
203
197
);
204
198
}
@@ -289,38 +283,6 @@ private static <R extends Collection<Integer>> DynamicTest shouldShortCircuitOnE
289
283
});
290
284
}
291
285
292
- private static <R extends Collection <Integer >> DynamicTest shouldRemainConsistent (CollectorSupplier <Function <Integer , Integer >, Executor , Integer , Collector <Integer , ?, CompletableFuture <R >>> collector , String name ) {
293
- return dynamicTest (format ("%s: should remain consistent" , name ), () -> {
294
- int parallelism = 100 ;
295
-
296
- ExecutorService executor = Executors .newFixedThreadPool (parallelism );
297
-
298
- try {
299
- List <Integer > elements = IntStream .range (0 , parallelism ).boxed ().toList ();
300
-
301
- CountDownLatch countDownLatch = new CountDownLatch (parallelism );
302
-
303
- R result = elements .stream ()
304
- .collect (collector .apply (i -> {
305
- countDownLatch .countDown ();
306
- try {
307
- countDownLatch .await ();
308
- } catch (InterruptedException e ) {
309
- throw new RuntimeException (e );
310
- }
311
- return i ;
312
- }, executor , PARALLELISM ))
313
- .join ();
314
-
315
- assertThat (new HashSet <>(result ))
316
- .hasSameSizeAs (elements )
317
- .containsAll (elements );
318
- } finally {
319
- executor .shutdownNow ();
320
- }
321
- });
322
- }
323
-
324
286
private static <R extends Collection <Integer >> DynamicTest shouldRejectInvalidParallelism (CollectorSupplier <Function <Integer , Integer >, Executor , Integer , Collector <Integer , ?, CompletableFuture <R >>> collector , String name ) {
325
287
return dynamicTest (format ("%s: should reject invalid parallelism" , name ), () -> {
326
288
withExecutor (e -> {
0 commit comments