From 8c5b7a87ae1a08d3b5157449c9f1dc0b0a5cc48a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 14 Dec 2023 10:21:48 +0000 Subject: [PATCH] Adapt to latest changes in the locking model for context close See gh-38666 --- .../boot/SpringApplicationShutdownHookTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationShutdownHookTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationShutdownHookTests.java index bafe2688da89..0d821496e30d 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationShutdownHookTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationShutdownHookTests.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; @@ -113,7 +114,7 @@ void runWhenContextIsBeingClosedInAnotherThreadWaitsUntilContextIsInactive() thr Thread shutdownThread = new Thread(shutdownHook); shutdownThread.start(); // Shutdown thread should start waiting for context to become inactive - Awaitility.await().atMost(Duration.ofSeconds(30)).until(shutdownThread::getState, State.TIMED_WAITING::equals); + Awaitility.await().atMost(Duration.ofSeconds(30)).until(shutdownThread::getState, State.WAITING::equals); // Allow context thread to proceed, unblocking shutdown thread proceedWithClose.countDown(); contextThread.join(); @@ -252,7 +253,7 @@ protected void onClose() { } if (this.proceedWithClose != null) { try { - this.proceedWithClose.await(); + this.proceedWithClose.await(1, TimeUnit.MINUTES); } catch (InterruptedException ex) { Thread.currentThread().interrupt();