Skip to content

Commit

Permalink
Short-circuit CompletableFuture returned by Startables#deepStart on e…
Browse files Browse the repository at this point in the history
…xception
  • Loading branch information
pivovarit committed Sep 30, 2022
1 parent 14687a6 commit a325af9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion core/src/main/java/org/testcontainers/lifecycle/Startables.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ private CompletableFuture<Void> deepStart(
})
.toArray(CompletableFuture[]::new);

return CompletableFuture.allOf(futures);
return allOfFailfast(futures);
}

private static <T> CompletableFuture<Void> allOfFailfast(CompletableFuture<?>[] futures) {
CompletableFuture<Void> result = CompletableFuture.allOf(futures);
for (CompletableFuture<?> future : futures) {
future.whenComplete((t, ex) -> {
if (ex != null) {
result.completeExceptionally(ex);
}
});
}

return result;
}
}

0 comments on commit a325af9

Please sign in to comment.