From df9a6a0f4f275a72dcb21ff9b124c36a5809cf4b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 12 Jun 2019 12:40:11 +0100 Subject: [PATCH] Wait for up to 30s for access logs to be written during shutdown Closes gh-17119 --- .../embedded/undertow/UndertowReactiveWebServerFactory.java | 5 +++++ .../embedded/undertow/UndertowServletWebServerFactory.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java index d7a42b6a00..272cc7812f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.concurrent.TimeUnit; import io.undertow.Handlers; import io.undertow.Undertow; @@ -156,10 +157,14 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF try { accessLogReceiver.close(); worker.shutdown(); + worker.awaitTermination(30, TimeUnit.SECONDS); } catch (IOException ex) { throw new IllegalStateException(ex); } + catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } }; } catch (IOException ex) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index 840195341e..3e17e4fe6c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -28,6 +28,7 @@ import java.util.Collections; import java.util.EventListener; import java.util.List; import java.util.Set; +import java.util.concurrent.TimeUnit; import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContext; @@ -652,10 +653,14 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac try { this.accessLogReceiver.close(); this.worker.shutdown(); + this.worker.awaitTermination(30, TimeUnit.SECONDS); } catch (IOException ex) { throw new IllegalStateException(ex); } + catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } } }