From 25f7ea215d433a5c0adbe60cf8112a88eac31768 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 18 Dec 2015 11:28:52 +0000 Subject: [PATCH] Ensure InetUtils uses a non-daemon thread --- .../org/springframework/cloud/util/InetUtils.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/util/InetUtils.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/util/InetUtils.java index ecdfd263..9b93975d 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/util/InetUtils.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/util/InetUtils.java @@ -11,6 +11,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import org.springframework.util.SystemPropertyUtils; @@ -25,7 +26,16 @@ import lombok.extern.apachecommons.CommonsLog; @CommonsLog public class InetUtils { - private static ExecutorService executor = Executors.newSingleThreadExecutor(); + private static ExecutorService executor = Executors + .newSingleThreadExecutor(new ThreadFactory() { + @Override + public Thread newThread(Runnable r) { + Thread thread = new Thread(r); + thread.setName("spring.cloud.inetutils"); + thread.setDaemon(true); + return thread; + } + }); /** * Find the first non-loopback host info. If there were errors return a hostinfo with