Skip to content

Commit df9a6a0

Browse files
committed
Wait for up to 30s for access logs to be written during shutdown
Closes gh-17119
1 parent 2833f60 commit df9a6a0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Arrays;
2424
import java.util.Collection;
2525
import java.util.List;
26+
import java.util.concurrent.TimeUnit;
2627

2728
import io.undertow.Handlers;
2829
import io.undertow.Undertow;
@@ -156,10 +157,14 @@ private Closeable configureAccessLogHandler(Undertow.Builder builder, HttpHandle
156157
try {
157158
accessLogReceiver.close();
158159
worker.shutdown();
160+
worker.awaitTermination(30, TimeUnit.SECONDS);
159161
}
160162
catch (IOException ex) {
161163
throw new IllegalStateException(ex);
162164
}
165+
catch (InterruptedException ex) {
166+
Thread.currentThread().interrupt();
167+
}
163168
};
164169
}
165170
catch (IOException ex) {

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.EventListener;
2929
import java.util.List;
3030
import java.util.Set;
31+
import java.util.concurrent.TimeUnit;
3132

3233
import javax.servlet.ServletContainerInitializer;
3334
import javax.servlet.ServletContext;
@@ -652,10 +653,14 @@ public void contextDestroyed(ServletContextEvent sce) {
652653
try {
653654
this.accessLogReceiver.close();
654655
this.worker.shutdown();
656+
this.worker.awaitTermination(30, TimeUnit.SECONDS);
655657
}
656658
catch (IOException ex) {
657659
throw new IllegalStateException(ex);
658660
}
661+
catch (InterruptedException ex) {
662+
Thread.currentThread().interrupt();
663+
}
659664
}
660665

661666
}

0 commit comments

Comments
 (0)