1
|
|
package com.pivovarit.collectors; |
2
|
|
|
3
|
|
import java.util.List; |
4
|
|
import java.util.Spliterator; |
5
|
|
import java.util.concurrent.BlockingQueue; |
6
|
|
import java.util.concurrent.CompletableFuture; |
7
|
|
import java.util.concurrent.LinkedBlockingQueue; |
8
|
|
import java.util.function.Consumer; |
9
|
|
|
10
|
|
/** |
11
|
|
* @author Grzegorz Piwowarek |
12
|
|
*/ |
13
|
|
final class CompletionOrderSpliterator<T> implements Spliterator<T> { |
14
|
|
|
15
|
|
private final int initialSize; |
16
|
|
private final BlockingQueue<CompletableFuture<T>> completed = new LinkedBlockingQueue<>(); |
17
|
|
private int remaining; |
18
|
|
|
19
|
|
CompletionOrderSpliterator(List<CompletableFuture<T>> futures) { |
20
|
|
this.initialSize = futures.size(); |
21
|
|
this.remaining = initialSize; |
22
|
1
1. <init> : removed call to java/util/List::forEach → TIMED_OUT
|
futures.forEach(f -> f.whenComplete((__, ___) -> completed.add(f))); |
23
|
|
} |
24
|
|
|
25
|
|
@Override |
26
|
|
public boolean tryAdvance(Consumer<? super T> action) { |
27
|
3
1. tryAdvance : negated conditional → TIMED_OUT
2. tryAdvance : changed conditional boundary → TIMED_OUT
3. tryAdvance : replaced boolean return with true for com/pivovarit/collectors/CompletionOrderSpliterator::tryAdvance → KILLED
|
return remaining > 0 |
28
|
1
1. lambda$tryAdvance$2 : replaced Boolean return with False for com/pivovarit/collectors/CompletionOrderSpliterator::lambda$tryAdvance$2 → KILLED
|
? nextCompleted().thenAccept(action).thenApply(__ -> true).join() |
29
|
|
: false; |
30
|
|
} |
31
|
|
|
32
|
|
private CompletableFuture<T> nextCompleted() { |
33
|
1
1. nextCompleted : Replaced integer subtraction with addition → TIMED_OUT
|
remaining--; |
34
|
|
try { |
35
|
1
1. nextCompleted : replaced return value with null for com/pivovarit/collectors/CompletionOrderSpliterator::nextCompleted → KILLED
|
return completed.take(); |
36
|
|
} catch (InterruptedException e) { |
37
|
1
1. nextCompleted : removed call to java/lang/Thread::interrupt → TIMED_OUT
|
Thread.currentThread().interrupt(); |
38
|
|
|
39
|
|
throw new RuntimeException(e); |
40
|
|
} |
41
|
|
} |
42
|
|
|
43
|
|
@Override |
44
|
|
public Spliterator<T> trySplit() { |
45
|
|
return null; |
46
|
|
} |
47
|
|
|
48
|
|
@Override |
49
|
|
public long estimateSize() { |
50
|
1
1. estimateSize : replaced long return with 0 for com/pivovarit/collectors/CompletionOrderSpliterator::estimateSize → KILLED
|
return initialSize; |
51
|
|
} |
52
|
|
|
53
|
|
@Override |
54
|
|
public int characteristics() { |
55
|
1
1. characteristics : replaced int return with 0 for com/pivovarit/collectors/CompletionOrderSpliterator::characteristics → SURVIVED
|
return SIZED | IMMUTABLE | NONNULL; |
56
|
|
} |
57
|
|
} |
58
|
|
|
59
|
|
|
| | Mutations |
22 |
|
1.1 Location : <init> Killed by : none removed call to java/util/List::forEach → TIMED_OUT
|
27 |
|
1.1 Location : tryAdvance Killed by : none negated conditional → TIMED_OUT
2.2 Location : tryAdvance Killed by : com.pivovarit.collectors.CompletionOrderSpliteratorTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.CompletionOrderSpliteratorTest]/[method:shouldNotConsumeOnEmpty()] replaced boolean return with true for com/pivovarit/collectors/CompletionOrderSpliterator::tryAdvance → KILLED
3.3 Location : tryAdvance Killed by : none changed conditional boundary → TIMED_OUT
|
28 |
|
1.1 Location : lambda$tryAdvance$2 Killed by : com.pivovarit.collectors.CompletionOrderSpliteratorTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.CompletionOrderSpliteratorTest]/[method:shouldPropagateException()] replaced Boolean return with False for com/pivovarit/collectors/CompletionOrderSpliterator::lambda$tryAdvance$2 → KILLED
|
33 |
|
1.1 Location : nextCompleted Killed by : none Replaced integer subtraction with addition → TIMED_OUT
|
35 |
|
1.1 Location : nextCompleted Killed by : com.pivovarit.collectors.CompletionOrderSpliteratorTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.CompletionOrderSpliteratorTest]/[method:shouldStreamInCompletionOrder()] replaced return value with null for com/pivovarit/collectors/CompletionOrderSpliterator::nextCompleted → KILLED
|
37 |
|
1.1 Location : nextCompleted Killed by : none removed call to java/lang/Thread::interrupt → TIMED_OUT
|
50 |
|
1.1 Location : estimateSize Killed by : com.pivovarit.collectors.CompletionOrderSpliteratorTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.CompletionOrderSpliteratorTest]/[method:shouldPropagateException()] replaced long return with 0 for com/pivovarit/collectors/CompletionOrderSpliterator::estimateSize → KILLED
|
55 |
|
1.1 Location : characteristics Killed by : none replaced int return with 0 for com/pivovarit/collectors/CompletionOrderSpliterator::characteristics → SURVIVED
Covering tests
Covered by tests:
- com.pivovarit.collectors.CompletionOrderSpliteratorTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.CompletionOrderSpliteratorTest]/[method:shouldStreamInCompletionOrder()]
- com.pivovarit.collectors.CompletionOrderSpliteratorTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.CompletionOrderSpliteratorTest]/[method:shouldPropagateException()]
- com.pivovarit.collectors.CompletionOrderSpliteratorTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.CompletionOrderSpliteratorTest]/[method:shouldTraverseInCompletionOrder()]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldProcessEmpty()]/[dynamic-test:#10]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#29]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#72]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#51]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#18]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#39]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#84]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#40]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#6]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#28]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#73]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#50]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#17]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#62]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#83]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#7]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldProcessEmpty()]/[dynamic-test:#13]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldProcessEmpty()]/[dynamic-test:#12]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldProcessEmpty()]/[dynamic-test:#11]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessEmptyWithMaxParallelism()]/[dynamic-test:#61]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldProcessAllElements()]/[dynamic-test:#10]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#72]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#83]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#50]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#61]
- com.pivovarit.collectors.test.RejectedExecutionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.RejectedExecutionHandlingTest]/[test-factory:shouldRejectInvalidRejectedExecutionHandlerWhenParallelismOneFactory()]/[dynamic-test:#3]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#39]
- com.pivovarit.collectors.test.ExceptionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExceptionHandlingTest]/[test-factory:shouldPropagateExceptionFactory()]/[dynamic-test:#10]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldStartProcessingImmediately()]/[dynamic-test:#11]
- com.pivovarit.collectors.test.ExceptionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExceptionHandlingTest]/[test-factory:shouldPropagateExceptionFactory()]/[dynamic-test:#11]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#28]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldProcessAllElements()]/[dynamic-test:#11]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldStartProcessingImmediately()]/[dynamic-test:#10]
- com.pivovarit.collectors.test.ExceptionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExceptionHandlingTest]/[test-factory:shouldShortcircuitOnException()]/[dynamic-test:#11]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldStartProcessingImmediately()]/[dynamic-test:#13]
- com.pivovarit.collectors.test.RejectedExecutionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.RejectedExecutionHandlingTest]/[test-factory:shouldRejectInvalidRejectedExecutionHandlerFactory()]/[dynamic-test:#4]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#17]
- com.pivovarit.collectors.test.ExceptionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExceptionHandlingTest]/[test-factory:shouldShortcircuitOnException()]/[dynamic-test:#12]
- com.pivovarit.collectors.test.RejectedExecutionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.RejectedExecutionHandlingTest]/[test-factory:shouldRejectInvalidRejectedExecutionHandlerFactory()]/[dynamic-test:#5]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldProcessAllElements()]/[dynamic-test:#12]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldStartProcessingImmediately()]/[dynamic-test:#12]
- com.pivovarit.collectors.test.ExceptionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExceptionHandlingTest]/[test-factory:shouldPropagateExceptionFactory()]/[dynamic-test:#12]
- com.pivovarit.collectors.test.ExceptionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExceptionHandlingTest]/[test-factory:shouldShortcircuitOnException()]/[dynamic-test:#10]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldProcessAllElements()]/[dynamic-test:#13]
- com.pivovarit.collectors.test.ExceptionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExceptionHandlingTest]/[test-factory:shouldShortcircuitOnException()]/[dynamic-test:#13]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#84]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#6]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#18]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#73]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#40]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#51]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#7]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#29]
- com.pivovarit.collectors.test.ExceptionHandlingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExceptionHandlingTest]/[test-factory:shouldPropagateExceptionFactory()]/[dynamic-test:#13]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldProcessAllElementsWithMaxParallelism()]/[dynamic-test:#62]
- com.pivovarit.collectors.test.StreamingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.StreamingTest]/[test-factory:shouldPushElementsAsSoonAsTheyAreReady()]/[dynamic-test:#3]
- com.pivovarit.collectors.test.StreamingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.StreamingTest]/[test-factory:shouldPushElementsAsSoonAsTheyAreReady()]/[dynamic-test:#1]
- com.pivovarit.collectors.test.StreamingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.StreamingTest]/[test-factory:shouldPushElementsAsSoonAsTheyAreReady()]/[dynamic-test:#2]
- com.pivovarit.collectors.test.ExecutorPollutionTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExecutorPollutionTest]/[test-factory:shouldNotPolluteExecutorFactoryLimitedParallelism()]/[dynamic-test:#3]
- com.pivovarit.collectors.test.ExecutorPollutionTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.ExecutorPollutionTest]/[test-factory:shouldNotPolluteExecutorFactory()]/[dynamic-test:#3]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldInterruptOnException()]/[dynamic-test:#12]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldInterruptOnException()]/[dynamic-test:#11]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldInterruptOnException()]/[dynamic-test:#13]
- com.pivovarit.collectors.test.BasicProcessingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicProcessingTest]/[test-factory:shouldInterruptOnException()]/[dynamic-test:#10]
- com.pivovarit.collectors.test.StreamingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.StreamingTest]/[test-factory:shouldCollectInCompletionOrder()]/[dynamic-test:#2]
- com.pivovarit.collectors.test.StreamingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.StreamingTest]/[test-factory:shouldCollectInCompletionOrder()]/[dynamic-test:#3]
- com.pivovarit.collectors.test.StreamingTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.StreamingTest]/[test-factory:shouldCollectInCompletionOrder()]/[dynamic-test:#1]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldRespectMaxParallelism()]/[dynamic-test:#7]
- com.pivovarit.collectors.test.BasicParallelismTest.[engine:junit-jupiter]/[class:com.pivovarit.collectors.test.BasicParallelismTest]/[test-factory:shouldRespectMaxParallelism()]/[dynamic-test:#6]
|