diff --git a/client/src/main/java/com/alibaba/nacos/client/auth/impl/process/HttpLoginProcessor.java b/client/src/main/java/com/alibaba/nacos/client/auth/impl/process/HttpLoginProcessor.java index 5cafb05f3..27ec860d7 100644 --- a/client/src/main/java/com/alibaba/nacos/client/auth/impl/process/HttpLoginProcessor.java +++ b/client/src/main/java/com/alibaba/nacos/client/auth/impl/process/HttpLoginProcessor.java @@ -67,8 +67,8 @@ public class HttpLoginProcessor implements LoginProcessor { url = server + contextPath + LOGIN_URL; } - Map params = new HashMap(2); - Map bodyMap = new HashMap(2); + Map params = new HashMap<>(2); + Map bodyMap = new HashMap<>(2); params.put(PropertyKeyConst.USERNAME, properties.getProperty(PropertyKeyConst.USERNAME, StringUtils.EMPTY)); bodyMap.put(PropertyKeyConst.PASSWORD, properties.getProperty(PropertyKeyConst.PASSWORD, StringUtils.EMPTY)); try { diff --git a/client/src/main/java/com/alibaba/nacos/client/auth/ram/identify/CredentialService.java b/client/src/main/java/com/alibaba/nacos/client/auth/ram/identify/CredentialService.java index da66bab21..b49a848a8 100644 --- a/client/src/main/java/com/alibaba/nacos/client/auth/ram/identify/CredentialService.java +++ b/client/src/main/java/com/alibaba/nacos/client/auth/ram/identify/CredentialService.java @@ -31,7 +31,7 @@ public final class CredentialService implements SpasCredentialLoader { private static final Logger LOGGER = LogUtils.logger(CredentialService.class); - private static final ConcurrentHashMap INSTANCES = new ConcurrentHashMap(); + private static final ConcurrentHashMap INSTANCES = new ConcurrentHashMap<>(); private final String appName; diff --git a/client/src/main/java/com/alibaba/nacos/client/auth/ram/utils/SpasAdapter.java b/client/src/main/java/com/alibaba/nacos/client/auth/ram/utils/SpasAdapter.java index 9a6b421d1..d317053ea 100644 --- a/client/src/main/java/com/alibaba/nacos/client/auth/ram/utils/SpasAdapter.java +++ b/client/src/main/java/com/alibaba/nacos/client/auth/ram/utils/SpasAdapter.java @@ -45,7 +45,7 @@ public class SpasAdapter { private static final String SHA_ENCRYPT = "HmacSHA1"; public static Map getSignHeaders(String resource, String secretKey) { - Map header = new HashMap(2); + Map header = new HashMap<>(2); String timeStamp = String.valueOf(System.currentTimeMillis()); header.put(TIMESTAMP_HEADER, timeStamp); if (secretKey != null) { diff --git a/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigContext.java b/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigContext.java index 74761586a..142f51f67 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigContext.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigContext.java @@ -28,7 +28,7 @@ import java.util.Map; */ public class ConfigContext implements IConfigContext { - private final Map param = new HashMap(); + private final Map param = new HashMap<>(); @Override public Object getParameter(String key) { diff --git a/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigRequest.java b/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigRequest.java index 16b1d9a4e..404039276 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigRequest.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigRequest.java @@ -36,7 +36,7 @@ import static com.alibaba.nacos.client.config.common.ConfigConstants.TYPE; */ public class ConfigRequest implements IConfigRequest { - private final Map param = new HashMap(); + private final Map param = new HashMap<>(); private final IConfigContext configContext = new ConfigContext(); diff --git a/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigResponse.java b/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigResponse.java index 6644adee1..c5d3e4735 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigResponse.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigResponse.java @@ -36,7 +36,7 @@ import static com.alibaba.nacos.client.config.common.ConfigConstants.TENANT; */ public class ConfigResponse implements IConfigResponse { - private final Map param = new HashMap(); + private final Map param = new HashMap<>(); private final IConfigContext configContext = new ConfigContext(); diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/AbstractConfigChangeParser.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/AbstractConfigChangeParser.java index a7cd5ec70..0e8596b79 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/AbstractConfigChangeParser.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/AbstractConfigChangeParser.java @@ -42,7 +42,7 @@ public abstract class AbstractConfigChangeParser implements ConfigChangeParser { } protected Map filterChangeData(Map oldMap, Map newMap) { - Map result = new HashMap(16); + Map result = new HashMap<>(16); for (Map.Entry e : (Iterable>) oldMap.entrySet()) { ConfigChangeItem cci; if (newMap.containsKey(e.getKey())) { diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/CacheData.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/CacheData.java index 1bc230a19..0de44f037 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/CacheData.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/CacheData.java @@ -202,7 +202,7 @@ public class CacheData { * Returns the iterator on the listener list, read-only. It is guaranteed not to return NULL. */ public List getListeners() { - List result = new ArrayList(); + List result = new ArrayList<>(); for (ManagerListenerWrap wrap : listeners) { result.add(wrap.listener); } diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java index c5efb0895..8d491f346 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java @@ -521,7 +521,7 @@ public class ClientWorker implements Closeable { public class ConfigRpcTransportClient extends ConfigTransportClient { - private final BlockingQueue listenExecutebell = new ArrayBlockingQueue(1); + private final BlockingQueue listenExecutebell = new ArrayBlockingQueue<>(1); private Object bellItem = new Object(); @@ -575,7 +575,7 @@ public class ClientWorker implements Closeable { private Map getLabels() { - Map labels = new HashMap(2, 1); + Map labels = new HashMap<>(2, 1); labels.put(RemoteConstants.LABEL_SOURCE, RemoteConstants.LABEL_SOURCE_SDK); labels.put(RemoteConstants.LABEL_MODULE, RemoteConstants.LABEL_MODULE_CONFIG); labels.put(Constants.APPNAME, AppNameUtils.getAppName()); @@ -714,8 +714,8 @@ public class ClientWorker implements Closeable { @Override public void executeConfigListen() { - Map> listenCachesMap = new HashMap>(16); - Map> removeListenCachesMap = new HashMap>(16); + Map> listenCachesMap = new HashMap<>(16); + Map> removeListenCachesMap = new HashMap<>(16); long now = System.currentTimeMillis(); boolean needAllSync = now - lastAllSyncTime >= ALL_SYNC_INTERNAL; for (CacheData cache : cacheMap.get().values()) { @@ -778,7 +778,7 @@ public class ClientWorker implements Closeable { rpcClient, configChangeListenRequest); if (configChangeBatchListenResponse != null && configChangeBatchListenResponse.isSuccess()) { - Set changeKeys = new HashSet(); + Set changeKeys = new HashSet<>(); //handle changed keys,notify listener if (!CollectionUtils.isEmpty(configChangeBatchListenResponse.getChangedConfigs())) { hasChangedKeys = true; diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigChangeHandler.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigChangeHandler.java index ef6f9488d..fe2a5ceaf 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigChangeHandler.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigChangeHandler.java @@ -40,7 +40,7 @@ public class ConfigChangeHandler { } private ConfigChangeHandler() { - this.parserList = new LinkedList(); + this.parserList = new LinkedList<>(); Collection loader = NacosServiceLoader.load(ConfigChangeParser.class); Iterator itr = loader.iterator(); diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigTransportClient.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigTransportClient.java index 85f931878..dcb0ca0aa 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigTransportClient.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigTransportClient.java @@ -104,7 +104,7 @@ public abstract class ConfigTransportClient { * @return headers. */ protected Map getCommonHeader() { - Map headers = new HashMap(16); + Map headers = new HashMap<>(16); String ts = String.valueOf(System.currentTimeMillis()); String token = MD5Utils.md5Hex(ts + ParamUtil.getAppKey(), Constants.ENCODE); diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/YmlChangeParser.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/YmlChangeParser.java index acb66d67e..8b6b22e7f 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/YmlChangeParser.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/YmlChangeParser.java @@ -77,7 +77,7 @@ public class YmlChangeParser extends AbstractConfigChangeParser { } private Map getFlattenedMap(Map source) { - Map result = new LinkedHashMap(128); + Map result = new LinkedHashMap<>(128); buildFlattenedMap(result, source, null); return result; } diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java index 644d2e422..7e55c22bc 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java @@ -186,23 +186,23 @@ public class NacosNamingService implements NamingService { @Override public List getAllInstances(String serviceName) throws NacosException { - return getAllInstances(serviceName, new ArrayList()); + return getAllInstances(serviceName, new ArrayList<>()); } @Override public List getAllInstances(String serviceName, String groupName) throws NacosException { - return getAllInstances(serviceName, groupName, new ArrayList()); + return getAllInstances(serviceName, groupName, new ArrayList<>()); } @Override public List getAllInstances(String serviceName, boolean subscribe) throws NacosException { - return getAllInstances(serviceName, new ArrayList(), subscribe); + return getAllInstances(serviceName, new ArrayList<>(), subscribe); } @Override public List getAllInstances(String serviceName, String groupName, boolean subscribe) throws NacosException { - return getAllInstances(serviceName, groupName, new ArrayList(), subscribe); + return getAllInstances(serviceName, groupName, new ArrayList<>(), subscribe); } @Override @@ -237,14 +237,14 @@ public class NacosNamingService implements NamingService { } List list; if (serviceInfo == null || CollectionUtils.isEmpty(list = serviceInfo.getHosts())) { - return new ArrayList(); + return new ArrayList<>(); } return list; } @Override public List selectInstances(String serviceName, boolean healthy) throws NacosException { - return selectInstances(serviceName, new ArrayList(), healthy); + return selectInstances(serviceName, new ArrayList<>(), healthy); } @Override @@ -255,13 +255,13 @@ public class NacosNamingService implements NamingService { @Override public List selectInstances(String serviceName, boolean healthy, boolean subscribe) throws NacosException { - return selectInstances(serviceName, new ArrayList(), healthy, subscribe); + return selectInstances(serviceName, new ArrayList<>(), healthy, subscribe); } @Override public List selectInstances(String serviceName, String groupName, boolean healthy, boolean subscribe) throws NacosException { - return selectInstances(serviceName, groupName, new ArrayList(), healthy, subscribe); + return selectInstances(serviceName, groupName, new ArrayList<>(), healthy, subscribe); } @Override @@ -302,7 +302,7 @@ public class NacosNamingService implements NamingService { private List selectInstances(ServiceInfo serviceInfo, boolean healthy) { List list; if (serviceInfo == null || CollectionUtils.isEmpty(list = serviceInfo.getHosts())) { - return new ArrayList(); + return new ArrayList<>(); } Iterator iterator = list.iterator(); @@ -318,7 +318,7 @@ public class NacosNamingService implements NamingService { @Override public Instance selectOneHealthyInstance(String serviceName) throws NacosException { - return selectOneHealthyInstance(serviceName, new ArrayList()); + return selectOneHealthyInstance(serviceName, new ArrayList<>()); } @Override @@ -328,13 +328,13 @@ public class NacosNamingService implements NamingService { @Override public Instance selectOneHealthyInstance(String serviceName, boolean subscribe) throws NacosException { - return selectOneHealthyInstance(serviceName, new ArrayList(), subscribe); + return selectOneHealthyInstance(serviceName, new ArrayList<>(), subscribe); } @Override public Instance selectOneHealthyInstance(String serviceName, String groupName, boolean subscribe) throws NacosException { - return selectOneHealthyInstance(serviceName, groupName, new ArrayList(), subscribe); + return selectOneHealthyInstance(serviceName, groupName, new ArrayList<>(), subscribe); } @Override @@ -373,12 +373,12 @@ public class NacosNamingService implements NamingService { @Override public void subscribe(String serviceName, EventListener listener) throws NacosException { - subscribe(serviceName, new ArrayList(), listener); + subscribe(serviceName, new ArrayList<>(), listener); } @Override public void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException { - subscribe(serviceName, groupName, new ArrayList(), listener); + subscribe(serviceName, groupName, new ArrayList<>(), listener); } @Override @@ -399,12 +399,12 @@ public class NacosNamingService implements NamingService { @Override public void unsubscribe(String serviceName, EventListener listener) throws NacosException { - unsubscribe(serviceName, new ArrayList(), listener); + unsubscribe(serviceName, new ArrayList<>(), listener); } @Override public void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException { - unsubscribe(serviceName, groupName, new ArrayList(), listener); + unsubscribe(serviceName, groupName, new ArrayList<>(), listener); } @Override diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java b/client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java index b6897f7bf..92815cf47 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java @@ -59,9 +59,9 @@ public class FailoverReactor implements Closeable { private static final String FAILOVER_MODE_PARAM = "failover-mode"; - private Map serviceMap = new ConcurrentHashMap(); + private Map serviceMap = new ConcurrentHashMap<>(); - private final Map switchParams = new ConcurrentHashMap(); + private final Map switchParams = new ConcurrentHashMap<>(); private static final long DAY_PERIOD_MINUTES = 24 * 60; @@ -184,7 +184,7 @@ public class FailoverReactor implements Closeable { @Override public void run() { - Map domMap = new HashMap(16); + Map domMap = new HashMap<>(16); BufferedReader reader = null; try { diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/beat/BeatReactor.java b/client/src/main/java/com/alibaba/nacos/client/naming/beat/BeatReactor.java index 848edf3a6..1acb4d608 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/beat/BeatReactor.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/beat/BeatReactor.java @@ -56,7 +56,7 @@ public class BeatReactor implements Closeable { private boolean lightBeatEnabled = false; - public final Map dom2Beat = new ConcurrentHashMap(); + public final Map dom2Beat = new ConcurrentHashMap<>(); public BeatReactor(NamingHttpClientProxy serverProxy) { this(serverProxy, null); diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java b/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java index d7659fa7b..6c614eabb 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java @@ -90,7 +90,7 @@ public class DiskCache { * @return service infos */ public static Map read(String cacheDir) { - Map domMap = new HashMap(16); + Map domMap = new HashMap<>(16); BufferedReader reader = null; try { @@ -109,7 +109,7 @@ public class DiskCache { if (!(fileName.endsWith(Constants.SERVICE_INFO_SPLITER + "meta") || fileName .endsWith(Constants.SERVICE_INFO_SPLITER + "special-url"))) { ServiceInfo dom = new ServiceInfo(fileName); - List ips = new ArrayList(); + List ips = new ArrayList<>(); dom.setHosts(ips); ServiceInfo newFormat = null; diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/cache/ServiceInfoHolder.java b/client/src/main/java/com/alibaba/nacos/client/naming/cache/ServiceInfoHolder.java index ebc34b0db..303ee249d 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/cache/ServiceInfoHolder.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/cache/ServiceInfoHolder.java @@ -191,20 +191,20 @@ public class ServiceInfoHolder implements Closeable { return false; } boolean changed = false; - Map oldHostMap = new HashMap(oldService.getHosts().size()); + Map oldHostMap = new HashMap<>(oldService.getHosts().size()); for (Instance host : oldService.getHosts()) { oldHostMap.put(host.toInetAddr(), host); } - Map newHostMap = new HashMap(newService.getHosts().size()); + Map newHostMap = new HashMap<>(newService.getHosts().size()); for (Instance host : newService.getHosts()) { newHostMap.put(host.toInetAddr(), host); } - Set modHosts = new HashSet(); - Set newHosts = new HashSet(); - Set remvHosts = new HashSet(); + Set modHosts = new HashSet<>(); + Set newHosts = new HashSet<>(); + Set remvHosts = new HashSet<>(); - List> newServiceHosts = new ArrayList>( + List> newServiceHosts = new ArrayList<>( newHostMap.entrySet()); for (Map.Entry entry : newServiceHosts) { Instance host = entry.getValue(); diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/core/Balancer.java b/client/src/main/java/com/alibaba/nacos/client/naming/core/Balancer.java index 66d2f777d..b4dab6bc3 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/core/Balancer.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/core/Balancer.java @@ -83,14 +83,14 @@ public class Balancer { return null; } NAMING_LOGGER.debug("new Chooser"); - List> hostsWithWeight = new ArrayList>(); + List> hostsWithWeight = new ArrayList<>(); for (Instance host : hosts) { if (host.isHealthy()) { hostsWithWeight.add(new Pair(host, host.getWeight())); } } NAMING_LOGGER.debug("for (Host host : hosts)"); - Chooser vipChooser = new Chooser("www.taobao.com"); + Chooser vipChooser = new Chooser<>("www.taobao.com"); vipChooser.refresh(hostsWithWeight); NAMING_LOGGER.debug("vipChooser.refresh"); return vipChooser.randomWithWeight(); diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/core/ServerListManager.java b/client/src/main/java/com/alibaba/nacos/client/naming/core/ServerListManager.java index 9f208a695..14ac914a4 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/core/ServerListManager.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/core/ServerListManager.java @@ -125,7 +125,7 @@ public class ServerListManager implements ServerListFactory, Closeable { "Error while requesting: " + urlString + "'. Server returned: " + restResult.getCode()); } String content = restResult.getData(); - List list = new ArrayList(); + List list = new ArrayList<>(); for (String line : IoUtils.readLines(new StringReader(content))) { if (!line.trim().isEmpty()) { list.add(line.trim()); diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/core/ServiceInfoUpdateService.java b/client/src/main/java/com/alibaba/nacos/client/naming/core/ServiceInfoUpdateService.java index e18e4485b..ddb0d619f 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/core/ServiceInfoUpdateService.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/core/ServiceInfoUpdateService.java @@ -51,7 +51,7 @@ public class ServiceInfoUpdateService implements Closeable { private static final int DEFAULT_UPDATE_CACHE_TIME_MULTIPLE = 6; - private final Map> futureMap = new HashMap>(); + private final Map> futureMap = new HashMap<>(); private final ServiceInfoHolder serviceInfoHolder; diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/event/InstancesChangeNotifier.java b/client/src/main/java/com/alibaba/nacos/client/naming/event/InstancesChangeNotifier.java index 6211d82f0..95293a416 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/event/InstancesChangeNotifier.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/event/InstancesChangeNotifier.java @@ -43,7 +43,7 @@ public class InstancesChangeNotifier extends Subscriber { private final String eventScope; - private final Map> listenerMap = new ConcurrentHashMap>(); + private final Map> listenerMap = new ConcurrentHashMap<>(); private final Object lock = new Object(); @@ -71,7 +71,7 @@ public class InstancesChangeNotifier extends Subscriber { synchronized (lock) { eventListeners = listenerMap.get(key); if (eventListeners == null) { - eventListeners = new ConcurrentHashSet(); + eventListeners = new ConcurrentHashSet<>(); listenerMap.put(key, eventListeners); } } @@ -114,7 +114,7 @@ public class InstancesChangeNotifier extends Subscriber { } public List getSubscribeServices() { - List serviceInfos = new ArrayList(); + List serviceInfos = new ArrayList<>(); for (String key : listenerMap.keySet()) { serviceInfos.add(ServiceInfo.fromKey(key)); } diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/NamingGrpcClientProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/NamingGrpcClientProxy.java index 55bdb71a1..04df631aa 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/NamingGrpcClientProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/NamingGrpcClientProxy.java @@ -80,7 +80,7 @@ public class NamingGrpcClientProxy extends AbstractNamingClientProxy { this.namespaceId = namespaceId; this.uuid = UUID.randomUUID().toString(); this.requestTimeout = Long.parseLong(properties.getProperty(CommonParams.NAMING_REQUEST_TIMEOUT, "-1")); - Map labels = new HashMap(); + Map labels = new HashMap<>(); labels.put(RemoteConstants.LABEL_SOURCE, RemoteConstants.LABEL_SOURCE_SDK); labels.put(RemoteConstants.LABEL_MODULE, RemoteConstants.LABEL_MODULE_NAMING); this.rpcClient = RpcClientFactory.createClient(uuid, ConnectionType.GRPC, labels); @@ -199,7 +199,7 @@ public class NamingGrpcClientProxy extends AbstractNamingClientProxy { } } ServiceListResponse response = requestToServer(request, ServiceListResponse.class); - ListView result = new ListView(); + ListView result = new ListView<>(); result.setCount(response.getCount()); result.setData(response.getServiceNames()); return result; diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java index fcfb4b394..19d8bb916 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java @@ -150,7 +150,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { BeatInfo beatInfo = beatReactor.buildBeatInfo(groupedServiceName, instance); beatReactor.addBeatInfo(groupedServiceName, beatInfo); } - final Map params = new HashMap(32); + final Map params = new HashMap<>(32); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, groupedServiceName); params.put(CommonParams.GROUP_NAME, groupName); @@ -176,7 +176,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { beatReactor.removeBeatInfo(NamingUtils.getGroupedName(serviceName, groupName), instance.getIp(), instance.getPort()); } - final Map params = new HashMap(16); + final Map params = new HashMap<>(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, NamingUtils.getGroupedName(serviceName, groupName)); params.put(CommonParams.CLUSTER_NAME, instance.getClusterName()); @@ -192,7 +192,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { NAMING_LOGGER .info("[UPDATE-SERVICE] {} update service {} with instance: {}", namespaceId, serviceName, instance); - final Map params = new HashMap(32); + final Map params = new HashMap<>(32); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, serviceName); params.put(CommonParams.GROUP_NAME, groupName); @@ -210,7 +210,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { @Override public ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters, int udpPort, boolean healthyOnly) throws NacosException { - final Map params = new HashMap(16); + final Map params = new HashMap<>(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, NamingUtils.getGroupedName(serviceName, groupName)); params.put(CLUSTERS_PARAM, clusters); @@ -228,7 +228,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { public Service queryService(String serviceName, String groupName) throws NacosException { NAMING_LOGGER.info("[QUERY-SERVICE] {} query service : {}, {}", namespaceId, serviceName, groupName); - final Map params = new HashMap(16); + final Map params = new HashMap<>(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, serviceName); params.put(CommonParams.GROUP_NAME, groupName); @@ -242,7 +242,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { NAMING_LOGGER.info("[CREATE-SERVICE] {} creating service : {}", namespaceId, service); - final Map params = new HashMap(16); + final Map params = new HashMap<>(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, service.getName()); params.put(CommonParams.GROUP_NAME, service.getGroupName()); @@ -259,7 +259,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { NAMING_LOGGER.info("[DELETE-SERVICE] {} deleting service : {} with groupName : {}", namespaceId, serviceName, groupName); - final Map params = new HashMap(16); + final Map params = new HashMap<>(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, serviceName); params.put(CommonParams.GROUP_NAME, groupName); @@ -272,7 +272,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { public void updateService(Service service, AbstractSelector selector) throws NacosException { NAMING_LOGGER.info("[UPDATE-SERVICE] {} updating service : {}", namespaceId, service); - final Map params = new HashMap(16); + final Map params = new HashMap<>(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, service.getName()); params.put(CommonParams.GROUP_NAME, service.getGroupName()); @@ -296,8 +296,8 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { if (NAMING_LOGGER.isDebugEnabled()) { NAMING_LOGGER.debug("[BEAT] {} sending beat to server: {}", namespaceId, beatInfo.toString()); } - Map params = new HashMap(16); - Map bodyMap = new HashMap(2); + Map params = new HashMap<>(16); + Map bodyMap = new HashMap<>(2); if (!lightBeatEnabled) { bodyMap.put("beat", JacksonUtils.toJson(beatInfo)); } @@ -314,7 +314,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { public boolean serverHealthy() { try { - String result = reqApi(UtilAndComs.nacosUrlBase + "/operator/metrics", new HashMap(8), + String result = reqApi(UtilAndComs.nacosUrlBase + "/operator/metrics", new HashMap<>(8), HttpMethod.GET); JsonNode json = JacksonUtils.toObj(result); String serverStatus = json.get("status").asText(); @@ -328,7 +328,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { public ListView getServiceList(int pageNo, int pageSize, String groupName, AbstractSelector selector) throws NacosException { - Map params = new HashMap(16); + Map params = new HashMap<>(16); params.put("pageNo", String.valueOf(pageNo)); params.put("pageSize", String.valueOf(pageSize)); params.put(CommonParams.NAMESPACE_ID, namespaceId); @@ -350,7 +350,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { String result = reqApi(UtilAndComs.nacosUrlBase + "/service/list", params, HttpMethod.GET); JsonNode json = JacksonUtils.toObj(result); - ListView listView = new ListView(); + ListView listView = new ListView<>(); listView.setCount(json.get("count").asInt()); listView.setData(JacksonUtils.toObj(json.get("doms").toString(), new TypeReference>() { })); diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/utils/Chooser.java b/client/src/main/java/com/alibaba/nacos/client/naming/utils/Chooser.java index ee5ca9f32..b681ef77f 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/utils/Chooser.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/utils/Chooser.java @@ -80,7 +80,7 @@ public class Chooser { } public Chooser(K uniqueKey, List> pairs) { - Ref ref = new Ref(pairs); + Ref ref = new Ref<>(pairs); ref.refresh(); this.uniqueKey = uniqueKey; this.ref = ref; @@ -100,7 +100,7 @@ public class Chooser { * @param itemsWithWeight items with weight */ public void refresh(List> itemsWithWeight) { - Ref newRef = new Ref(itemsWithWeight); + Ref newRef = new Ref<>(itemsWithWeight); newRef.refresh(); newRef.poller = this.ref.poller.refresh(newRef.items); this.ref = newRef; @@ -108,11 +108,11 @@ public class Chooser { public class Ref { - private List> itemsWithWeight = new ArrayList>(); + private List> itemsWithWeight = new ArrayList<>(); - private final List items = new ArrayList(); + private final List items = new ArrayList<>(); - private Poller poller = new GenericPoller(items); + private Poller poller = new GenericPoller<>(items); private double[] weights; diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/utils/GenericPoller.java b/client/src/main/java/com/alibaba/nacos/client/naming/utils/GenericPoller.java index fc01ff5c5..c16268c6b 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/utils/GenericPoller.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/utils/GenericPoller.java @@ -29,7 +29,7 @@ public class GenericPoller implements Poller { private final AtomicInteger index = new AtomicInteger(0); - private List items = new ArrayList(); + private List items = new ArrayList<>(); public GenericPoller(List items) { this.items = items; @@ -42,6 +42,6 @@ public class GenericPoller implements Poller { @Override public Poller refresh(List items) { - return new GenericPoller(items); + return new GenericPoller<>(items); } }