Skip to content

Commit ec3af86

Browse files
committed
Ensure task entry index is not sparse
1 parent 06418ca commit ec3af86

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

junit-platform-engine/src/main/java/org/junit/platform/engine/support/hierarchical/ConcurrentHierarchicalTestExecutorService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,17 @@ void invokeAll(List<? extends TestTask> testTasks) {
276276
private List<WorkQueue.Entry> forkConcurrentChildren(List<? extends TestTask> children,
277277
Consumer<TestTask> isolatedTaskCollector, List<TestTask> sameThreadTasks) {
278278

279+
int index = 0;
279280
List<WorkQueue.Entry> queueEntries = new ArrayList<>(children.size());
280-
for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) {
281-
TestTask child = children.get(i);
281+
for (TestTask child : children) {
282282
if (requiresGlobalReadWriteLock(child)) {
283283
isolatedTaskCollector.accept(child);
284284
}
285285
else if (child.getExecutionMode() == SAME_THREAD) {
286286
sameThreadTasks.add(child);
287287
}
288288
else {
289-
queueEntries.add(WorkQueue.Entry.createIndexed(i, child));
289+
queueEntries.add(WorkQueue.Entry.createWithIndex(child, index++));
290290
}
291291
}
292292

@@ -579,7 +579,7 @@ static Entry create(TestTask task) {
579579
return new Entry(task, new CompletableFuture<>(), level, 0);
580580
}
581581

582-
static Entry createIndexed(int index, TestTask task) {
582+
static Entry createWithIndex(TestTask task, int index) {
583583
int level = task.getTestDescriptor().getUniqueId().getSegments().size();
584584
return new Entry(task, new CompletableFuture<>(), level, index);
585585
}

0 commit comments

Comments
 (0)