diff --git a/common/src/main/java/com/alibaba/nacos/common/executor/ExecutorFactory.java b/common/src/main/java/com/alibaba/nacos/common/executor/ExecutorFactory.java index 23b169d9d..071408b8a 100644 --- a/common/src/main/java/com/alibaba/nacos/common/executor/ExecutorFactory.java +++ b/common/src/main/java/com/alibaba/nacos/common/executor/ExecutorFactory.java @@ -68,7 +68,7 @@ public final class ExecutorFactory { public static ThreadPoolExecutor newCustomerThreadExecutor(final int coreThreads, final int maxThreads, final long keepAliveTimeMs, final ThreadFactory threadFactory) { return new ThreadPoolExecutor(coreThreads, maxThreads, keepAliveTimeMs, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(), threadFactory); + new LinkedBlockingQueue<>(), threadFactory); } public static final class Managed { @@ -172,7 +172,7 @@ public final class ExecutorFactory { public static ThreadPoolExecutor newCustomerThreadExecutor(final String group, final int coreThreads, final int maxThreads, final long keepAliveTimeMs, final ThreadFactory threadFactory) { ThreadPoolExecutor executor = new ThreadPoolExecutor(coreThreads, maxThreads, keepAliveTimeMs, - TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), threadFactory); + TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), threadFactory); THREAD_POOL_MANAGER.register(DEFAULT_NAMESPACE, group, executor); return executor; } diff --git a/common/src/main/java/com/alibaba/nacos/common/executor/ThreadPoolManager.java b/common/src/main/java/com/alibaba/nacos/common/executor/ThreadPoolManager.java index 74bd862ff..e4ce5822b 100644 --- a/common/src/main/java/com/alibaba/nacos/common/executor/ThreadPoolManager.java +++ b/common/src/main/java/com/alibaba/nacos/common/executor/ThreadPoolManager.java @@ -44,7 +44,7 @@ public final class ThreadPoolManager { private Map>> resourcesManager; - private Map lockers = new ConcurrentHashMap(8); + private Map lockers = new ConcurrentHashMap<>(8); private static final ThreadPoolManager INSTANCE = new ThreadPoolManager(); @@ -67,7 +67,7 @@ public final class ThreadPoolManager { } private void init() { - resourcesManager = new ConcurrentHashMap>>(8); + resourcesManager = new ConcurrentHashMap<>(8); } /** @@ -85,7 +85,7 @@ public final class ThreadPoolManager { synchronized (monitor) { Map> map = resourcesManager.get(namespace); if (map == null) { - map = new HashMap>(8); + map = new HashMap<>(8); map.computeIfAbsent(group, key -> new HashSet<>()).add(executor); resourcesManager.put(namespace, map); return; diff --git a/common/src/main/java/com/alibaba/nacos/common/http/HttpClientBeanHolder.java b/common/src/main/java/com/alibaba/nacos/common/http/HttpClientBeanHolder.java index f29b5d438..873df0fb8 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/HttpClientBeanHolder.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/HttpClientBeanHolder.java @@ -36,9 +36,9 @@ public final class HttpClientBeanHolder { private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientBeanHolder.class); - private static final Map SINGLETON_REST = new HashMap(10); + private static final Map SINGLETON_REST = new HashMap<>(10); - private static final Map SINGLETON_ASYNC_REST = new HashMap( + private static final Map SINGLETON_ASYNC_REST = new HashMap<>( 10); private static final AtomicBoolean ALREADY_SHUTDOWN = new AtomicBoolean(false); diff --git a/common/src/main/java/com/alibaba/nacos/common/http/HttpUtils.java b/common/src/main/java/com/alibaba/nacos/common/http/HttpUtils.java index df32baca2..88aa3d096 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/HttpUtils.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/HttpUtils.java @@ -114,7 +114,7 @@ public final class HttpUtils { if (body == null || body.isEmpty()) { return; } - List params = new ArrayList(body.size()); + List params = new ArrayList<>(body.size()); for (Map.Entry entry : body.entrySet()) { params.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } @@ -176,7 +176,7 @@ public final class HttpUtils { * @throws Exception exception */ public static Map translateParameterMap(Map parameterMap) throws Exception { - Map map = new HashMap(16); + Map map = new HashMap<>(16); for (Map.Entry entry : parameterMap.entrySet()) { map.put(entry.getKey(), entry.getValue()[0]); } diff --git a/common/src/main/java/com/alibaba/nacos/common/http/client/NacosRestTemplate.java b/common/src/main/java/com/alibaba/nacos/common/http/client/NacosRestTemplate.java index 1d60c2e4c..9b165d744 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/client/NacosRestTemplate.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/client/NacosRestTemplate.java @@ -49,7 +49,7 @@ public class NacosRestTemplate extends AbstractNacosRestTemplate { private final HttpClientRequest requestClient; - private final List interceptors = new ArrayList(); + private final List interceptors = new ArrayList<>(); public NacosRestTemplate(Logger logger, HttpClientRequest requestClient) { super(logger); diff --git a/common/src/main/java/com/alibaba/nacos/common/http/client/handler/AbstractResponseHandler.java b/common/src/main/java/com/alibaba/nacos/common/http/client/handler/AbstractResponseHandler.java index 049188371..6c80d7ef3 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/client/handler/AbstractResponseHandler.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/client/handler/AbstractResponseHandler.java @@ -49,7 +49,7 @@ public abstract class AbstractResponseHandler implements ResponseHandler { private HttpRestResult handleError(HttpClientResponse response) throws Exception { Header headers = response.getHeaders(); String message = IoUtils.toString(response.getBody(), headers.getCharset()); - return new HttpRestResult(headers, response.getStatusCode(), null, message); + return new HttpRestResult<>(headers, response.getStatusCode(), null, message); } /** diff --git a/common/src/main/java/com/alibaba/nacos/common/http/client/handler/BeanResponseHandler.java b/common/src/main/java/com/alibaba/nacos/common/http/client/handler/BeanResponseHandler.java index 70c531534..1e8b655ad 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/client/handler/BeanResponseHandler.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/client/handler/BeanResponseHandler.java @@ -37,6 +37,6 @@ public class BeanResponseHandler extends AbstractResponseHandler { final Header headers = response.getHeaders(); InputStream body = response.getBody(); T extractBody = JacksonUtils.toObj(body, responseType); - return new HttpRestResult(headers, response.getStatusCode(), extractBody, null); + return new HttpRestResult<>(headers, response.getStatusCode(), extractBody, null); } } diff --git a/common/src/main/java/com/alibaba/nacos/common/http/client/handler/RestResultResponseHandler.java b/common/src/main/java/com/alibaba/nacos/common/http/client/handler/RestResultResponseHandler.java index ec83b6aec..10886cac2 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/client/handler/RestResultResponseHandler.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/client/handler/RestResultResponseHandler.java @@ -44,7 +44,7 @@ public class RestResultResponseHandler extends AbstractResponseHandler { } private static HttpRestResult convert(RestResult restResult) { - HttpRestResult httpRestResult = new HttpRestResult(); + HttpRestResult httpRestResult = new HttpRestResult<>(); httpRestResult.setCode(restResult.getCode()); httpRestResult.setData(restResult.getData()); httpRestResult.setMessage(restResult.getMessage()); diff --git a/common/src/main/java/com/alibaba/nacos/common/http/client/handler/StringResponseHandler.java b/common/src/main/java/com/alibaba/nacos/common/http/client/handler/StringResponseHandler.java index 43ca2cb44..8e776dc5c 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/client/handler/StringResponseHandler.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/client/handler/StringResponseHandler.java @@ -34,6 +34,6 @@ public class StringResponseHandler extends AbstractResponseHandler { public HttpRestResult convertResult(HttpClientResponse response, Type responseType) throws Exception { final Header headers = response.getHeaders(); String extractBody = IoUtils.toString(response.getBody(), headers.getCharset()); - return new HttpRestResult(headers, response.getStatusCode(), extractBody, null); + return new HttpRestResult<>(headers, response.getStatusCode(), extractBody, null); } } diff --git a/common/src/main/java/com/alibaba/nacos/common/http/param/Header.java b/common/src/main/java/com/alibaba/nacos/common/http/param/Header.java index 616e1c471..98dc8efc7 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/param/Header.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/param/Header.java @@ -45,8 +45,8 @@ public class Header { private static final String DEFAULT_ENCODING = "gzip"; private Header() { - header = new TreeMap(String.CASE_INSENSITIVE_ORDER); - originalResponseHeader = new TreeMap>(String.CASE_INSENSITIVE_ORDER); + header = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + originalResponseHeader = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); addParam(HttpHeaderConsts.CONTENT_TYPE, MediaType.APPLICATION_JSON); addParam(HttpHeaderConsts.ACCEPT_CHARSET, DEFAULT_CHARSET); //addParam(HttpHeaderConsts.ACCEPT_ENCODING, DEFAULT_ENCODING); @@ -99,7 +99,7 @@ public class Header { * @return KV string list */ public List toList() { - List list = new ArrayList(header.size() * 2); + List list = new ArrayList<>(header.size() * 2); Iterator> iterator = iterator(); while (iterator.hasNext()) { Map.Entry entry = iterator.next(); diff --git a/common/src/main/java/com/alibaba/nacos/common/http/param/Query.java b/common/src/main/java/com/alibaba/nacos/common/http/param/Query.java index 4c6027f31..a3056b15c 100644 --- a/common/src/main/java/com/alibaba/nacos/common/http/param/Query.java +++ b/common/src/main/java/com/alibaba/nacos/common/http/param/Query.java @@ -41,7 +41,7 @@ public class Query { private static final String DEFAULT_ENC = "UTF-8"; public Query() { - params = new LinkedHashMap(); + params = new LinkedHashMap<>(); } public static Query newInstance() { diff --git a/common/src/main/java/com/alibaba/nacos/common/model/RestResult.java b/common/src/main/java/com/alibaba/nacos/common/model/RestResult.java index e97c30b7d..aa31cb4f6 100644 --- a/common/src/main/java/com/alibaba/nacos/common/model/RestResult.java +++ b/common/src/main/java/com/alibaba/nacos/common/model/RestResult.java @@ -86,7 +86,7 @@ public class RestResult implements Serializable { } public static ResResultBuilder builder() { - return new ResResultBuilder(); + return new ResResultBuilder<>(); } public static final class ResResultBuilder { @@ -121,7 +121,7 @@ public class RestResult implements Serializable { * @return result */ public RestResult build() { - RestResult restResult = new RestResult(); + RestResult restResult = new RestResult<>(); restResult.setCode(code); restResult.setMessage(errMsg); restResult.setData(data); diff --git a/common/src/main/java/com/alibaba/nacos/common/notify/DefaultSharePublisher.java b/common/src/main/java/com/alibaba/nacos/common/notify/DefaultSharePublisher.java index 26c62be91..ab8c989e3 100644 --- a/common/src/main/java/com/alibaba/nacos/common/notify/DefaultSharePublisher.java +++ b/common/src/main/java/com/alibaba/nacos/common/notify/DefaultSharePublisher.java @@ -47,7 +47,7 @@ public class DefaultSharePublisher extends DefaultPublisher implements ShardedEv try { Set sets = subMappings.get(subSlowEventType); if (sets == null) { - Set newSet = new ConcurrentHashSet(); + Set newSet = new ConcurrentHashSet<>(); newSet.add(subscriber); subMappings.put(subSlowEventType, newSet); return; diff --git a/common/src/main/java/com/alibaba/nacos/common/spi/NacosServiceLoader.java b/common/src/main/java/com/alibaba/nacos/common/spi/NacosServiceLoader.java index 2bd058884..315073365 100644 --- a/common/src/main/java/com/alibaba/nacos/common/spi/NacosServiceLoader.java +++ b/common/src/main/java/com/alibaba/nacos/common/spi/NacosServiceLoader.java @@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap; */ public class NacosServiceLoader { - private static final Map, Collection>> SERVICES = new ConcurrentHashMap, Collection>>(); + private static final Map, Collection>> SERVICES = new ConcurrentHashMap<>(); /** * Load service. @@ -45,7 +45,7 @@ public class NacosServiceLoader { if (SERVICES.containsKey(service)) { return newServiceInstances(service); } - Collection result = new LinkedHashSet(); + Collection result = new LinkedHashSet<>(); for (T each : ServiceLoader.load(service)) { result.add(each); cacheServiceClass(service, each); @@ -55,7 +55,7 @@ public class NacosServiceLoader { private static void cacheServiceClass(final Class service, final T instance) { if (!SERVICES.containsKey(service)) { - SERVICES.put(service, new LinkedHashSet>()); + SERVICES.put(service, new LinkedHashSet<>()); } SERVICES.get(service).add(instance.getClass()); } @@ -73,7 +73,7 @@ public class NacosServiceLoader { @SuppressWarnings("unchecked") private static Collection newServiceInstancesFromCache(Class service) { - Collection result = new LinkedHashSet(); + Collection result = new LinkedHashSet<>(); for (Class each : SERVICES.get(service)) { result.add((T) newServiceInstance(each)); } diff --git a/common/src/main/java/com/alibaba/nacos/common/task/engine/NacosDelayTaskExecuteEngine.java b/common/src/main/java/com/alibaba/nacos/common/task/engine/NacosDelayTaskExecuteEngine.java index 23ff94d9e..ea8d97c57 100644 --- a/common/src/main/java/com/alibaba/nacos/common/task/engine/NacosDelayTaskExecuteEngine.java +++ b/common/src/main/java/com/alibaba/nacos/common/task/engine/NacosDelayTaskExecuteEngine.java @@ -104,7 +104,7 @@ public class NacosDelayTaskExecuteEngine extends AbstractNacosTaskExecuteEngine< @Override public Collection getAllTaskKeys() { - Collection keys = new HashSet(); + Collection keys = new HashSet<>(); lock.lock(); try { keys.addAll(tasks.keySet()); diff --git a/common/src/main/java/com/alibaba/nacos/common/task/engine/TaskExecuteWorker.java b/common/src/main/java/com/alibaba/nacos/common/task/engine/TaskExecuteWorker.java index 63ad61e40..f220d7534 100644 --- a/common/src/main/java/com/alibaba/nacos/common/task/engine/TaskExecuteWorker.java +++ b/common/src/main/java/com/alibaba/nacos/common/task/engine/TaskExecuteWorker.java @@ -54,7 +54,7 @@ public final class TaskExecuteWorker implements NacosTaskProcessor, Closeable { public TaskExecuteWorker(final String name, final int mod, final int total, final Logger logger) { this.name = name + "_" + mod + "%" + total; - this.queue = new ArrayBlockingQueue(QUEUE_CAPACITY); + this.queue = new ArrayBlockingQueue<>(QUEUE_CAPACITY); this.closed = new AtomicBoolean(false); this.log = null == logger ? LoggerFactory.getLogger(TaskExecuteWorker.class) : logger; new InnerWorker(name).start(); diff --git a/common/src/main/java/com/alibaba/nacos/common/utils/ConcurrentHashSet.java b/common/src/main/java/com/alibaba/nacos/common/utils/ConcurrentHashSet.java index f6617aa2e..855158eb1 100644 --- a/common/src/main/java/com/alibaba/nacos/common/utils/ConcurrentHashSet.java +++ b/common/src/main/java/com/alibaba/nacos/common/utils/ConcurrentHashSet.java @@ -31,7 +31,7 @@ public class ConcurrentHashSet extends AbstractSet { public ConcurrentHashSet() { super(); - map = new ConcurrentHashMap(); + map = new ConcurrentHashMap<>(); } @Override diff --git a/common/src/main/java/com/alibaba/nacos/common/utils/IoUtils.java b/common/src/main/java/com/alibaba/nacos/common/utils/IoUtils.java index 0e3801f35..98f4ebacc 100644 --- a/common/src/main/java/com/alibaba/nacos/common/utils/IoUtils.java +++ b/common/src/main/java/com/alibaba/nacos/common/utils/IoUtils.java @@ -149,7 +149,7 @@ public class IoUtils { */ public static List readLines(Reader input) throws IOException { BufferedReader reader = toBufferedReader(input); - List list = new ArrayList(); + List list = new ArrayList<>(); String line = null; for (; ; ) { line = reader.readLine(); diff --git a/common/src/main/java/com/alibaba/nacos/common/utils/Observable.java b/common/src/main/java/com/alibaba/nacos/common/utils/Observable.java index 341dbf642..de57cc4a4 100644 --- a/common/src/main/java/com/alibaba/nacos/common/utils/Observable.java +++ b/common/src/main/java/com/alibaba/nacos/common/utils/Observable.java @@ -28,7 +28,7 @@ public class Observable { private transient boolean changed = false; - private transient Set obs = new ConcurrentHashSet(); + private transient Set obs = new ConcurrentHashSet<>(); private volatile int observerCnt = 0;