Use newCachedTreadPool() instead of newSingleThreadExecutor() in InetUtils (#1365)

Co-authored-by: tsypanovs <serhii.tsypanov@dxc.com>
This commit is contained in:
Сергей Цыпанов
2024-09-25 14:33:24 +03:00
committed by GitHub
parent 697b60052f
commit 715fb9f540

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,10 +35,10 @@ import org.apache.commons.logging.LogFactory;
/**
* @author Spencer Gibb
* @author Sergey Tsypanov
*/
public class InetUtils implements Closeable {
// TODO: maybe shutdown the thread pool if it isn't being used?
private final ExecutorService executorService;
private final InetUtilsProperties properties;
@@ -47,7 +47,7 @@ public class InetUtils implements Closeable {
public InetUtils(final InetUtilsProperties properties) {
this.properties = properties;
this.executorService = Executors.newSingleThreadExecutor(r -> {
this.executorService = Executors.newCachedThreadPool(r -> {
Thread thread = new Thread(r);
thread.setName(InetUtilsProperties.PREFIX);
thread.setDaemon(true);