Ensure InetUtils uses a non-daemon thread

This commit is contained in:
Dave Syer
2015-12-18 11:28:52 +00:00
parent af26af4bfa
commit 25f7ea215d

View File

@@ -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