From b79ee145d613bac8a0a58b28fc600f7ef9086621 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 17 Dec 2015 11:30:17 +0000 Subject: [PATCH] =?UTF-8?q?Configure=20worker=20for=20Undertow=E2=80=99s?= =?UTF-8?q?=20access=20log=20to=20use=20daemon=20threads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the worker used non-daemon threads which meant that they prevented the JVM from shutting down. Ideally, we’d avoid this problem by closing the worker and access log receiver as part of stopping Undertow, however, due to an apparent bug in Undertow [1], it’s not possible to do so cleanly. This commit configures the access log worker to use daemon threads so that they do not prevent the JVM from shutting down. Unfortunately, this means that the threads will still be running after the context has been closed but before the JVM shuts down but that appears to be unavoidable due to the aforementioned Undertow bug. Closes gh-4793 [1] https://issues.jboss.org/browse/UNDERTOW-597 --- .../undertow/UndertowEmbeddedServletContainerFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java index eb8edc0e98c..e3a3e2ff4a4 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java @@ -405,8 +405,8 @@ public class UndertowEmbeddedServletContainerFactory private XnioWorker createWorker() throws IOException { Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader()); - OptionMap.Builder builder = OptionMap.builder(); - return xnio.createWorker(builder.getMap()); + return xnio.createWorker( + OptionMap.builder().set(Options.THREAD_DAEMON, true).getMap()); } private void registerServletContainerInitializerToDriveServletContextInitializers(