diff --git a/src/test/java/org/gridsuite/ds/server/controller/DynamicSimulationControllerTest.java b/src/test/java/org/gridsuite/ds/server/controller/DynamicSimulationControllerTest.java index 3623250..e23bdaa 100644 --- a/src/test/java/org/gridsuite/ds/server/controller/DynamicSimulationControllerTest.java +++ b/src/test/java/org/gridsuite/ds/server/controller/DynamicSimulationControllerTest.java @@ -448,8 +448,12 @@ private UUID runAndCancel(CountDownLatch cancelLatch, int cancelDelay) throws Ex assertRunningStatus(runUuid); - // stop dynamic simulation - cancelLatch.await(); + // stop dynamic simulation, need a timeout to avoid test hangs if an exception occurs before latch countdown + boolean completed = cancelLatch.await(5, TimeUnit.SECONDS); + if (!completed) { + throw new AssertionError("Timed out waiting for cancelLatch, something might have crashed before latch countdown happens."); + } + // custom additional wait await().pollDelay(cancelDelay, TimeUnit.MILLISECONDS).until(() -> true);