Fix Sonar issue s2293 The diamond operator ('<>') should be used (#14005)

This commit is contained in:
jean pierre Lerbscher 2024-03-29 04:40:06 +01:00 committed by GitHub
parent 4be3587dd1
commit 00812ce41c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
91 changed files with 143 additions and 148 deletions

View File

@ -212,7 +212,7 @@ public class SingleRouterChain<T> {
public RouterSnapshotNode<T> buildRouterSnapshot( public RouterSnapshotNode<T> buildRouterSnapshot(
URL url, BitList<Invoker<T>> availableInvokers, Invocation invocation) { URL url, BitList<Invoker<T>> availableInvokers, Invocation invocation) {
BitList<Invoker<T>> resultInvokers = availableInvokers.clone(); BitList<Invoker<T>> resultInvokers = availableInvokers.clone();
RouterSnapshotNode<T> parentNode = new RouterSnapshotNode<T>("Parent", resultInvokers.clone()); RouterSnapshotNode<T> parentNode = new RouterSnapshotNode<>("Parent", resultInvokers.clone());
parentNode.setNodeOutputInvokers(resultInvokers.clone()); parentNode.setNodeOutputInvokers(resultInvokers.clone());
// 1. route state router // 1. route state router
@ -227,7 +227,7 @@ public class SingleRouterChain<T> {
return parentNode; return parentNode;
} }
RouterSnapshotNode<T> commonRouterNode = new RouterSnapshotNode<T>("CommonRouter", resultInvokers.clone()); RouterSnapshotNode<T> commonRouterNode = new RouterSnapshotNode<>("CommonRouter", resultInvokers.clone());
parentNode.appendNode(commonRouterNode); parentNode.appendNode(commonRouterNode);
List<Invoker<T>> commonRouterResult = resultInvokers; List<Invoker<T>> commonRouterResult = resultInvokers;
@ -237,7 +237,7 @@ public class SingleRouterChain<T> {
List<Invoker<T>> inputInvokers = new ArrayList<>(commonRouterResult); List<Invoker<T>> inputInvokers = new ArrayList<>(commonRouterResult);
RouterSnapshotNode<T> currentNode = RouterSnapshotNode<T> currentNode =
new RouterSnapshotNode<T>(router.getClass().getSimpleName(), inputInvokers); new RouterSnapshotNode<>(router.getClass().getSimpleName(), inputInvokers);
// append to router node chain // append to router node chain
commonRouterNode.appendNode(currentNode); commonRouterNode.appendNode(currentNode);

View File

@ -223,7 +223,7 @@ public abstract class AbstractConfigurator implements Configurator {
} }
private Set<String> genConditionKeys() { private Set<String> genConditionKeys() {
Set<String> conditionKeys = new HashSet<String>(); Set<String> conditionKeys = new HashSet<>();
conditionKeys.add(CATEGORY_KEY); conditionKeys.add(CATEGORY_KEY);
conditionKeys.add(Constants.CHECK_KEY); conditionKeys.add(Constants.CHECK_KEY);
conditionKeys.add(DYNAMIC_KEY); conditionKeys.add(DYNAMIC_KEY);

View File

@ -46,8 +46,7 @@ public class ConsistentHashLoadBalance extends AbstractLoadBalance {
*/ */
public static final String HASH_ARGUMENTS = "hash.arguments"; public static final String HASH_ARGUMENTS = "hash.arguments";
private final ConcurrentMap<String, ConsistentHashSelector<?>> selectors = private final ConcurrentMap<String, ConsistentHashSelector<?>> selectors = new ConcurrentHashMap<>();
new ConcurrentHashMap<String, ConsistentHashSelector<?>>();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@ -75,7 +74,7 @@ public class ConsistentHashLoadBalance extends AbstractLoadBalance {
private final int[] argumentIndex; private final int[] argumentIndex;
ConsistentHashSelector(List<Invoker<T>> invokers, String methodName, int identityHashCode) { ConsistentHashSelector(List<Invoker<T>> invokers, String methodName, int identityHashCode) {
this.virtualInvokers = new TreeMap<Long, Invoker<T>>(); this.virtualInvokers = new TreeMap<>();
this.identityHashCode = identityHashCode; this.identityHashCode = identityHashCode;
URL url = invokers.get(0).getUrl(); URL url = invokers.get(0).getUrl();
this.replicaNumber = url.getMethodParameter(methodName, HASH_NODES, 160); this.replicaNumber = url.getMethodParameter(methodName, HASH_NODES, 160);

View File

@ -32,7 +32,7 @@ public class MapMerger implements Merger<Map<?, ?>> {
if (ArrayUtils.isEmpty(items)) { if (ArrayUtils.isEmpty(items)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
Map<Object, Object> result = new HashMap<Object, Object>(); Map<Object, Object> result = new HashMap<>();
Stream.of(items).filter(Objects::nonNull).forEach(result::putAll); Stream.of(items).filter(Objects::nonNull).forEach(result::putAll);
return result; return result;
} }

View File

@ -36,7 +36,7 @@ public class MergerFactory implements ScopeModelAware {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(MergerFactory.class); private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(MergerFactory.class);
private ConcurrentMap<Class<?>, Merger<?>> MERGER_CACHE = new ConcurrentHashMap<Class<?>, Merger<?>>(); private ConcurrentMap<Class<?>, Merger<?>> MERGER_CACHE = new ConcurrentHashMap<>();
private ScopeModel scopeModel; private ScopeModel scopeModel;
@Override @Override

View File

@ -32,7 +32,7 @@ public class SetMerger implements Merger<Set<?>> {
if (ArrayUtils.isEmpty(items)) { if (ArrayUtils.isEmpty(items)) {
return Collections.emptySet(); return Collections.emptySet();
} }
Set<Object> result = new HashSet<Object>(); Set<Object> result = new HashSet<>();
Stream.of(items).filter(Objects::nonNull).forEach(result::addAll); Stream.of(items).filter(Objects::nonNull).forEach(result::addAll);
return result; return result;
} }

View File

@ -30,6 +30,6 @@ public class ConditionStateRouterFactory extends CacheableStateRouterFactory {
@Override @Override
protected <T> StateRouter<T> createRouter(Class<T> interfaceClass, URL url) { protected <T> StateRouter<T> createRouter(Class<T> interfaceClass, URL url) {
return new ConditionStateRouter<T>(url); return new ConditionStateRouter<>(url);
} }
} }

View File

@ -32,6 +32,6 @@ public class ServiceStateRouterFactory extends CacheableStateRouterFactory {
@Override @Override
protected <T> StateRouter<T> createRouter(Class<T> interfaceClass, URL url) { protected <T> StateRouter<T> createRouter(Class<T> interfaceClass, URL url) {
return new ServiceStateRouter<T>(url); return new ServiceStateRouter<>(url);
} }
} }

View File

@ -136,7 +136,7 @@ public class MeshRuleCache<T> {
Collections.unmodifiableMap(totalSubsetMap), Collections.unmodifiableMap(totalSubsetMap),
unmatchedInvokers); unmatchedInvokers);
} else { } else {
return new MeshRuleCache<T>( return new MeshRuleCache<>(
Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap(), invokers); Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap(), invokers);
} }
} }

View File

@ -30,6 +30,6 @@ public class MockStateRouterFactory implements StateRouterFactory {
@Override @Override
public <T> StateRouter<T> getRouter(Class<T> interfaceClass, URL url) { public <T> StateRouter<T> getRouter(Class<T> interfaceClass, URL url) {
return new MockInvokersSelector<T>(url); return new MockInvokersSelector<>(url);
} }
} }

View File

@ -31,6 +31,6 @@ public class TagStateRouterFactory extends CacheableStateRouterFactory {
@Override @Override
protected <T> StateRouter<T> createRouter(Class<T> interfaceClass, URL url) { protected <T> StateRouter<T> createRouter(Class<T> interfaceClass, URL url) {
return new TagStateRouter<T>(url); return new TagStateRouter<>(url);
} }
} }

View File

@ -63,8 +63,8 @@ public class FailoverClusterInvoker<T> extends AbstractClusterInvoker<T> {
int len = calculateInvokeTimes(methodName); int len = calculateInvokeTimes(methodName);
// retry loop. // retry loop.
RpcException le = null; // last exception. RpcException le = null; // last exception.
List<Invoker<T>> invoked = new ArrayList<Invoker<T>>(copyInvokers.size()); // invoked invokers. List<Invoker<T>> invoked = new ArrayList<>(copyInvokers.size()); // invoked invokers.
Set<String> providers = new HashSet<String>(len); Set<String> providers = new HashSet<>(len);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
// Reselect before retry to avoid a change of candidate `invokers`. // Reselect before retry to avoid a change of candidate `invokers`.
// NOTE: if `invokers` changed, then `invoked` also lose accuracy. // NOTE: if `invokers` changed, then `invoked` also lose accuracy.

View File

@ -26,6 +26,6 @@ public class MergeableCluster extends AbstractCluster {
@Override @Override
public <T> AbstractClusterInvoker<T> doJoin(Directory<T> directory) throws RpcException { public <T> AbstractClusterInvoker<T> doJoin(Directory<T> directory) throws RpcException {
return new MergeableClusterInvoker<T>(directory); return new MergeableClusterInvoker<>(directory);
} }
} }

View File

@ -27,6 +27,6 @@ public class ZoneAwareCluster extends AbstractCluster {
@Override @Override
protected <T> AbstractClusterInvoker<T> doJoin(Directory<T> directory) throws RpcException { protected <T> AbstractClusterInvoker<T> doJoin(Directory<T> directory) throws RpcException {
return new ZoneAwareClusterInvoker<T>(directory); return new ZoneAwareClusterInvoker<>(directory);
} }
} }

View File

@ -35,7 +35,7 @@ public class MockClusterWrapper implements Cluster {
@Override @Override
public <T> Invoker<T> join(Directory<T> directory, boolean buildFilterChain) throws RpcException { public <T> Invoker<T> join(Directory<T> directory, boolean buildFilterChain) throws RpcException {
return new MockClusterInvoker<T>(directory, this.cluster.join(directory, buildFilterChain)); return new MockClusterInvoker<>(directory, this.cluster.join(directory, buildFilterChain));
} }
public Cluster getCluster() { public Cluster getCluster() {

View File

@ -60,7 +60,7 @@ public final class Version {
public static final int LOWEST_VERSION_FOR_RESPONSE_ATTACHMENT = 2000200; // 2.0.2 public static final int LOWEST_VERSION_FOR_RESPONSE_ATTACHMENT = 2000200; // 2.0.2
public static final int HIGHEST_PROTOCOL_VERSION = 2009900; // 2.0.99 public static final int HIGHEST_PROTOCOL_VERSION = 2009900; // 2.0.99
private static final Map<String, Integer> VERSION2INT = new HashMap<String, Integer>(); private static final Map<String, Integer> VERSION2INT = new HashMap<>();
static { static {
// get dubbo version and last commit id // get dubbo version and last commit id

View File

@ -35,7 +35,7 @@ import java.util.Map;
public final class JavaBeanSerializeUtil { public final class JavaBeanSerializeUtil {
private static final Logger logger = LoggerFactory.getLogger(JavaBeanSerializeUtil.class); private static final Logger logger = LoggerFactory.getLogger(JavaBeanSerializeUtil.class);
private static final Map<String, Class<?>> TYPES = new HashMap<String, Class<?>>(); private static final Map<String, Class<?>> TYPES = new HashMap<>();
private static final String ARRAY_PREFIX = "["; private static final String ARRAY_PREFIX = "[";
private static final String REFERENCE_TYPE_PREFIX = "L"; private static final String REFERENCE_TYPE_PREFIX = "L";
private static final String REFERENCE_TYPE_SUFFIX = ";"; private static final String REFERENCE_TYPE_SUFFIX = ";";
@ -72,7 +72,7 @@ public final class JavaBeanSerializeUtil {
if (obj instanceof JavaBeanDescriptor) { if (obj instanceof JavaBeanDescriptor) {
return (JavaBeanDescriptor) obj; return (JavaBeanDescriptor) obj;
} }
IdentityHashMap<Object, JavaBeanDescriptor> cache = new IdentityHashMap<Object, JavaBeanDescriptor>(); IdentityHashMap<Object, JavaBeanDescriptor> cache = new IdentityHashMap<>();
return createDescriptorIfAbsent(obj, accessor, cache); return createDescriptorIfAbsent(obj, accessor, cache);
} }
@ -209,7 +209,7 @@ public final class JavaBeanSerializeUtil {
if (beanDescriptor == null) { if (beanDescriptor == null) {
return null; return null;
} }
IdentityHashMap<JavaBeanDescriptor, Object> cache = new IdentityHashMap<JavaBeanDescriptor, Object>(); IdentityHashMap<JavaBeanDescriptor, Object> cache = new IdentityHashMap<>();
Object result = instantiateForDeserialize(beanDescriptor, loader, cache); Object result = instantiateForDeserialize(beanDescriptor, loader, cache);
deserializeInternal(result, beanDescriptor, loader, cache); deserializeInternal(result, beanDescriptor, loader, cache);
return result; return result;

View File

@ -120,7 +120,7 @@ public abstract class Mixin {
Class<?> neighbor = null; Class<?> neighbor = null;
// impl methods. // impl methods.
Set<String> worked = new HashSet<String>(); Set<String> worked = new HashSet<>();
for (int i = 0; i < ics.length; i++) { for (int i = 0; i < ics.length; i++) {
if (!Modifier.isPublic(ics[i].getModifiers())) { if (!Modifier.isPublic(ics[i].getModifiers())) {
String npkg = ics[i].getPackage().getName(); String npkg = ics[i].getPackage().getName();

View File

@ -42,8 +42,8 @@ import javassist.CtMethod;
* Wrapper. * Wrapper.
*/ */
public abstract class Wrapper { public abstract class Wrapper {
private static final ConcurrentMap<Class<?>, Wrapper> WRAPPER_MAP = // class wrapper map
new ConcurrentHashMap<Class<?>, Wrapper>(); // class wrapper map private static final ConcurrentMap<Class<?>, Wrapper> WRAPPER_MAP = new ConcurrentHashMap<>();
private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final String[] EMPTY_STRING_ARRAY = new String[0];
private static final String[] OBJECT_METHODS = new String[] {"getClass", "hashCode", "toString", "equals"}; private static final String[] OBJECT_METHODS = new String[] {"getClass", "hashCode", "toString", "equals"};
private static final Wrapper OBJECT_WRAPPER = new Wrapper() { private static final Wrapper OBJECT_WRAPPER = new Wrapper() {

View File

@ -392,7 +392,7 @@ public class ClassUtils {
} }
public static <K, V> Map<K, V> toMap(Map.Entry<K, V>[] entries) { public static <K, V> Map<K, V> toMap(Map.Entry<K, V>[] entries) {
Map<K, V> map = new HashMap<K, V>(); Map<K, V> map = new HashMap<>();
if (entries != null && entries.length > 0) { if (entries != null && entries.length > 0) {
for (Map.Entry<K, V> entry : entries) { for (Map.Entry<K, V> entry : entries) {
map.put(entry.getKey(), entry.getValue()); map.put(entry.getKey(), entry.getValue());

View File

@ -28,7 +28,7 @@ public final class InternalThreadLocalMap {
private Object[] indexedVariables; private Object[] indexedVariables;
private static ThreadLocal<InternalThreadLocalMap> slowThreadLocalMap = new ThreadLocal<InternalThreadLocalMap>(); private static ThreadLocal<InternalThreadLocalMap> slowThreadLocalMap = new ThreadLocal<>();
private static final AtomicInteger NEXT_INDEX = new AtomicInteger(); private static final AtomicInteger NEXT_INDEX = new AtomicInteger();

View File

@ -427,7 +427,7 @@ public class HashedWheelTimer implements Timer {
} }
private final class Worker implements Runnable { private final class Worker implements Runnable {
private final Set<Timeout> unprocessedTimeouts = new HashSet<Timeout>(); private final Set<Timeout> unprocessedTimeouts = new HashSet<>();
private long tick; private long tick;

View File

@ -98,7 +98,7 @@ public class CIDRUtils {
private byte[] toBytes(byte[] array, int targetSize) { private byte[] toBytes(byte[] array, int targetSize) {
int counter = 0; int counter = 0;
List<Byte> newArr = new ArrayList<Byte>(); List<Byte> newArr = new ArrayList<>();
while (counter < targetSize && (array.length - 1 - counter >= 0)) { while (counter < targetSize && (array.length - 1 - counter >= 0)) {
newArr.add(0, array[array.length - 1 - counter]); newArr.add(0, array[array.length - 1 - counter]);
counter++; counter++;

View File

@ -87,7 +87,7 @@ public class ConfigUtils {
*/ */
public static List<String> mergeValues( public static List<String> mergeValues(
ExtensionDirector extensionDirector, Class<?> type, String cfg, List<String> def) { ExtensionDirector extensionDirector, Class<?> type, String cfg, List<String> def) {
List<String> defaults = new ArrayList<String>(); List<String> defaults = new ArrayList<>();
if (def != null) { if (def != null) {
for (String name : def) { for (String name : def) {
if (extensionDirector.getExtensionLoader(type).hasExtension(name)) { if (extensionDirector.getExtensionLoader(type).hasExtension(name)) {
@ -96,7 +96,7 @@ public class ConfigUtils {
} }
} }
List<String> names = new ArrayList<String>(); List<String> names = new ArrayList<>();
// add initial values // add initial values
String[] configs = (cfg == null || cfg.trim().length() == 0) ? new String[0] : COMMA_SPLIT_PATTERN.split(cfg); String[] configs = (cfg == null || cfg.trim().length() == 0) ? new String[0] : COMMA_SPLIT_PATTERN.split(cfg);

View File

@ -179,7 +179,7 @@ public class IOUtils {
* @throws IOException If an I/O error occurs * @throws IOException If an I/O error occurs
*/ */
public static String[] readLines(InputStream is) throws IOException { public static String[] readLines(InputStream is) throws IOException {
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {

View File

@ -26,7 +26,7 @@ import java.util.List;
public class Stack<E> { public class Stack<E> {
private int mSize = 0; private int mSize = 0;
private final List<E> mElements = new ArrayList<E>(); private final List<E> mElements = new ArrayList<>();
public Stack() {} public Stack() {}

View File

@ -861,7 +861,7 @@ public final class StringUtils {
*/ */
private static Map<String, String> parseKeyValuePair(String str, String itemSeparator) { private static Map<String, String> parseKeyValuePair(String str, String itemSeparator) {
String[] tmp = str.split(itemSeparator); String[] tmp = str.split(itemSeparator);
Map<String, String> map = new HashMap<String, String>(tmp.length); Map<String, String> map = new HashMap<>(tmp.length);
for (int i = 0; i < tmp.length; i++) { for (int i = 0; i < tmp.length; i++) {
Matcher matcher = KVP_PATTERN.matcher(tmp[i]); Matcher matcher = KVP_PATTERN.matcher(tmp[i]);
if (!matcher.matches()) { if (!matcher.matches()) {
@ -885,7 +885,7 @@ public final class StringUtils {
*/ */
public static Map<String, String> parseQueryString(String qs) { public static Map<String, String> parseQueryString(String qs) {
if (isEmpty(qs)) { if (isEmpty(qs)) {
return new HashMap<String, String>(); return new HashMap<>();
} }
return parseKeyValuePair(qs, "\\&"); return parseKeyValuePair(qs, "\\&");
} }

View File

@ -181,7 +181,7 @@ public class UrlUtils {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Addresses is not allowed to be empty, please re-enter."); // here won't be empty "Addresses is not allowed to be empty, please re-enter."); // here won't be empty
} }
List<URL> registries = new ArrayList<URL>(); List<URL> registries = new ArrayList<>();
for (String addr : addresses) { for (String addr : addresses) {
registries.add(parseURL(addr, defaults)); registries.add(parseURL(addr, defaults));
} }

View File

@ -204,7 +204,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
/** /**
* The url of the reference service * The url of the reference service
*/ */
protected final transient List<URL> urls = new ArrayList<URL>(); protected final transient List<URL> urls = new ArrayList<>();
@Transient @Transient
public List<URL> getExportedUrls() { public List<URL> getExportedUrls() {

View File

@ -361,7 +361,7 @@ public class ApplicationConfig extends AbstractConfig {
} }
public void setRegistry(RegistryConfig registry) { public void setRegistry(RegistryConfig registry) {
List<RegistryConfig> registries = new ArrayList<RegistryConfig>(1); List<RegistryConfig> registries = new ArrayList<>(1);
registries.add(registry); registries.add(registry);
this.registries = registries; this.registries = registries;
} }

View File

@ -186,7 +186,7 @@ public class ModuleConfig extends AbstractConfig {
} }
public void setRegistry(RegistryConfig registry) { public void setRegistry(RegistryConfig registry) {
List<RegistryConfig> registries = new ArrayList<RegistryConfig>(1); List<RegistryConfig> registries = new ArrayList<>(1);
registries.add(registry); registries.add(registry);
this.registries = registries; this.registries = registries;
} }

View File

@ -96,7 +96,7 @@ public final class ClassUtils {
* @return methods list * @return methods list
*/ */
public static List<Method> getPublicNonStaticMethods(final Class<?> clazz) { public static List<Method> getPublicNonStaticMethods(final Class<?> clazz) {
List<Method> result = new ArrayList<Method>(); List<Method> result = new ArrayList<>();
Method[] methods = clazz.getMethods(); Method[] methods = clazz.getMethods();
for (Method method : methods) { for (Method method : methods) {

View File

@ -135,7 +135,7 @@ public class ProviderModel extends ServiceModel {
} }
public List<ProviderMethodModel> getAllMethodModels() { public List<ProviderMethodModel> getAllMethodModels() {
List<ProviderMethodModel> result = new ArrayList<ProviderMethodModel>(); List<ProviderMethodModel> result = new ArrayList<>();
for (List<ProviderMethodModel> models : methods.values()) { for (List<ProviderMethodModel> models : methods.values()) {
result.addAll(models); result.addAll(models);
} }

View File

@ -30,7 +30,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.METHOD_KEY;
@Deprecated @Deprecated
public abstract class AbstractCacheFactory implements CacheFactory { public abstract class AbstractCacheFactory implements CacheFactory {
private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<String, Cache>(); private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<>();
@Override @Override
public Cache getCache(URL url, Invocation invocation) { public Cache getCache(URL url, Invocation invocation) {

View File

@ -86,7 +86,7 @@ public class ServiceConfig<T> extends org.apache.dubbo.config.ServiceConfig<T> {
if (providers == null || providers.isEmpty()) { if (providers == null || providers.isEmpty()) {
return null; return null;
} }
List<ProtocolConfig> protocols = new ArrayList<ProtocolConfig>(providers.size()); List<ProtocolConfig> protocols = new ArrayList<>(providers.size());
for (ProviderConfig provider : providers) { for (ProviderConfig provider : providers) {
protocols.add(convertProviderToProtocol(provider)); protocols.add(convertProviderToProtocol(provider));
} }

View File

@ -57,8 +57,8 @@ public class Page {
} }
private static List<List<String>> stringToList(String str) { private static List<List<String>> stringToList(String str) {
List<List<String>> rows = new ArrayList<List<String>>(); List<List<String>> rows = new ArrayList<>();
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
row.add(str); row.add(str);
rows.add(row); rows.add(row);
return rows; return rows;

View File

@ -49,8 +49,8 @@ public class PageServlet extends HttpServlet {
private static final long serialVersionUID = -8370312705453328501L; private static final long serialVersionUID = -8370312705453328501L;
private static PageServlet INSTANCE; private static PageServlet INSTANCE;
protected final Random random = new Random(); protected final Random random = new Random();
protected final Map<String, PageHandler> pages = new ConcurrentHashMap<String, PageHandler>(); protected final Map<String, PageHandler> pages = new ConcurrentHashMap<>();
protected final List<PageHandler> menus = new ArrayList<PageHandler>(); protected final List<PageHandler> menus = new ArrayList<>();
public static PageServlet getInstance() { public static PageServlet getInstance() {
return INSTANCE; return INSTANCE;

View File

@ -46,7 +46,7 @@ public class ResourceFilter implements Filter {
private final long start = System.currentTimeMillis(); private final long start = System.currentTimeMillis();
private final List<String> resources = new ArrayList<String>(); private final List<String> resources = new ArrayList<>();
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
String config = filterConfig.getInitParameter("resources"); String config = filterConfig.getInitParameter("resources");

View File

@ -35,11 +35,11 @@ public class HomePageHandler implements PageHandler {
@Override @Override
public Page handle(URL url) { public Page handle(URL url) {
List<List<String>> rows = new ArrayList<List<String>>(); List<List<String>> rows = new ArrayList<>();
for (PageHandler handler : PageServlet.getInstance().getMenus()) { for (PageHandler handler : PageServlet.getInstance().getMenus()) {
String uri = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(handler); String uri = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(handler);
Menu menu = handler.getClass().getAnnotation(Menu.class); Menu menu = handler.getClass().getAnnotation(Menu.class);
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
row.add("<a href=\"" + uri + ".html\">" + menu.name() + "</a>"); row.add("<a href=\"" + uri + ".html\">" + menu.name() + "</a>");
row.add(menu.desc()); row.add(menu.desc());
rows.add(row); rows.add(row);

View File

@ -97,8 +97,8 @@ public class LogPageHandler implements PageHandler {
} }
} }
Level level = LogManager.getRootLogger().getLevel(); Level level = LogManager.getRootLogger().getLevel();
List<List<String>> rows = new ArrayList<List<String>>(); List<List<String>> rows = new ArrayList<>();
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
row.add(content); row.add(content);
rows.add(row); rows.add(row);
return new Page( return new Page(

View File

@ -40,14 +40,14 @@ public class StatusPageHandler implements PageHandler {
@Override @Override
public Page handle(URL url) { public Page handle(URL url) {
List<List<String>> rows = new ArrayList<List<String>>(); List<List<String>> rows = new ArrayList<>();
Set<String> names = Set<String> names =
ExtensionLoader.getExtensionLoader(StatusChecker.class).getSupportedExtensions(); ExtensionLoader.getExtensionLoader(StatusChecker.class).getSupportedExtensions();
Map<String, Status> statuses = new HashMap<String, Status>(); Map<String, Status> statuses = new HashMap<>();
for (String name : names) { for (String name : names) {
StatusChecker checker = StatusChecker checker =
ExtensionLoader.getExtensionLoader(StatusChecker.class).getExtension(name); ExtensionLoader.getExtensionLoader(StatusChecker.class).getExtension(name);
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
row.add(name); row.add(name);
Status status = checker.check(); Status status = checker.check();
if (status != null && !Status.Level.UNKNOWN.equals(status.getLevel())) { if (status != null && !Status.Level.UNKNOWN.equals(status.getLevel())) {
@ -61,7 +61,7 @@ public class StatusPageHandler implements PageHandler {
if ("status".equals(url.getPath())) { if ("status".equals(url.getPath())) {
return new Page("", "", "", status.getLevel().toString()); return new Page("", "", "", status.getLevel().toString());
} else { } else {
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
row.add("summary"); row.add("summary");
row.add(getLevelHtml(status.getLevel())); row.add(getLevelHtml(status.getLevel()));
row.add("<a href=\"/status\" target=\"_blank\">summary</a>"); row.add("<a href=\"/status\" target=\"_blank\">summary</a>");

View File

@ -44,49 +44,49 @@ public class SystemPageHandler implements PageHandler {
@Override @Override
public Page handle(URL url) { public Page handle(URL url) {
List<List<String>> rows = new ArrayList<List<String>>(); List<List<String>> rows = new ArrayList<>();
List<String> row; List<String> row;
row = new ArrayList<String>(); row = new ArrayList<>();
row.add("Version"); row.add("Version");
row.add(Version.getVersion(SystemPageHandler.class, "2.0.0")); row.add(Version.getVersion(SystemPageHandler.class, "2.0.0"));
rows.add(row); rows.add(row);
row = new ArrayList<String>(); row = new ArrayList<>();
row.add("Host"); row.add("Host");
String address = NetUtils.getLocalHost(); String address = NetUtils.getLocalHost();
row.add(NetUtils.getHostName(address) + "/" + address); row.add(NetUtils.getHostName(address) + "/" + address);
rows.add(row); rows.add(row);
row = new ArrayList<String>(); row = new ArrayList<>();
row.add("OS"); row.add("OS");
row.add(System.getProperty("os.name") + " " + System.getProperty("os.version")); row.add(System.getProperty("os.name") + " " + System.getProperty("os.version"));
rows.add(row); rows.add(row);
row = new ArrayList<String>(); row = new ArrayList<>();
row.add("JVM"); row.add("JVM");
row.add(System.getProperty("java.runtime.name") + " " + System.getProperty("java.runtime.version") + ",<br/>" row.add(System.getProperty("java.runtime.name") + " " + System.getProperty("java.runtime.version") + ",<br/>"
+ System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version") + " " + System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version") + " "
+ System.getProperty("java.vm.info", "")); + System.getProperty("java.vm.info", ""));
rows.add(row); rows.add(row);
row = new ArrayList<String>(); row = new ArrayList<>();
row.add("CPU"); row.add("CPU");
row.add(System.getProperty("os.arch", "") + ", " row.add(System.getProperty("os.arch", "") + ", "
+ String.valueOf(Runtime.getRuntime().availableProcessors()) + " cores"); + String.valueOf(Runtime.getRuntime().availableProcessors()) + " cores");
rows.add(row); rows.add(row);
row = new ArrayList<String>(); row = new ArrayList<>();
row.add("Locale"); row.add("Locale");
row.add(Locale.getDefault().toString() + "/" + System.getProperty("file.encoding")); row.add(Locale.getDefault().toString() + "/" + System.getProperty("file.encoding"));
rows.add(row); rows.add(row);
row = new ArrayList<String>(); row = new ArrayList<>();
row.add("Uptime"); row.add("Uptime");
row.add(formatUptime(ManagementFactory.getRuntimeMXBean().getUptime())); row.add(formatUptime(ManagementFactory.getRuntimeMXBean().getUptime()));
rows.add(row); rows.add(row);
row = new ArrayList<String>(); row = new ArrayList<>();
row.add("Time"); row.add("Time");
row.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z").format(new Date())); row.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z").format(new Date()));
rows.add(row); rows.add(row);

View File

@ -353,7 +353,7 @@ public class RpcContext {
final T o = callable.call(); final T o = callable.call();
// local invoke will return directly // local invoke will return directly
if (o != null) { if (o != null) {
FutureTask<T> f = new FutureTask<T>(new Callable<T>() { FutureTask<T> f = new FutureTask<>(new Callable<T>() {
@Override @Override
public T call() throws Exception { public T call() throws Exception {
return o; return o;

View File

@ -162,14 +162,14 @@ public class RpcInvocation implements Invocation, Serializable {
public void setAttachment(String key, String value) { public void setAttachment(String key, String value) {
if (attachments == null) { if (attachments == null) {
attachments = new HashMap<String, String>(); attachments = new HashMap<>();
} }
attachments.put(key, value); attachments.put(key, value);
} }
public void setAttachmentIfAbsent(String key, String value) { public void setAttachmentIfAbsent(String key, String value) {
if (attachments == null) { if (attachments == null) {
attachments = new HashMap<String, String>(); attachments = new HashMap<>();
} }
if (!attachments.containsKey(key)) { if (!attachments.containsKey(key)) {
attachments.put(key, value); attachments.put(key, value);
@ -181,7 +181,7 @@ public class RpcInvocation implements Invocation, Serializable {
return; return;
} }
if (this.attachments == null) { if (this.attachments == null) {
this.attachments = new HashMap<String, String>(); this.attachments = new HashMap<>();
} }
this.attachments.putAll(attachments); this.attachments.putAll(attachments);
} }

View File

@ -128,7 +128,7 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
/** /**
* A random port cache, the different protocols who have no port specified have different random port * A random port cache, the different protocols who have no port specified have different random port
*/ */
private static final Map<String, Integer> RANDOM_PORT_MAP = new HashMap<String, Integer>(); private static final Map<String, Integer> RANDOM_PORT_MAP = new HashMap<>();
private Protocol protocolSPI; private Protocol protocolSPI;
@ -651,7 +651,7 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
private Map<String, String> buildAttributes(ProtocolConfig protocolConfig) { private Map<String, String> buildAttributes(ProtocolConfig protocolConfig) {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<>();
map.put(SIDE_KEY, PROVIDER_SIDE); map.put(SIDE_KEY, PROVIDER_SIDE);
// append params with basic configs, // append params with basic configs,

View File

@ -209,7 +209,7 @@ public class ConfigValidationUtils {
address = ANYHOST_VALUE; address = ANYHOST_VALUE;
} }
if (!RegistryConfig.NO_AVAILABLE.equalsIgnoreCase(address)) { if (!RegistryConfig.NO_AVAILABLE.equalsIgnoreCase(address)) {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<>();
AbstractConfig.appendParameters(map, application); AbstractConfig.appendParameters(map, application);
AbstractConfig.appendParameters(map, config); AbstractConfig.appendParameters(map, config);
map.put(PATH_KEY, RegistryService.class.getName()); map.put(PATH_KEY, RegistryService.class.getName());
@ -309,7 +309,7 @@ public class ConfigValidationUtils {
} }
public static URL loadMonitor(AbstractInterfaceConfig interfaceConfig, URL registryURL) { public static URL loadMonitor(AbstractInterfaceConfig interfaceConfig, URL registryURL) {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<>();
map.put(INTERFACE_KEY, MonitorService.class.getName()); map.put(INTERFACE_KEY, MonitorService.class.getName());
AbstractInterfaceConfig.appendRuntimeParameters(map); AbstractInterfaceConfig.appendRuntimeParameters(map);
// set ip // set ip

View File

@ -78,8 +78,7 @@ public abstract class AbstractAnnotationBeanPostProcessor
private final Class<? extends Annotation>[] annotationTypes; private final Class<? extends Annotation>[] annotationTypes;
private final ConcurrentMap<String, AbstractAnnotationBeanPostProcessor.AnnotatedInjectionMetadata> private final ConcurrentMap<String, AbstractAnnotationBeanPostProcessor.AnnotatedInjectionMetadata>
injectionMetadataCache = new ConcurrentHashMap< injectionMetadataCache = new ConcurrentHashMap<>(CACHE_SIZE);
String, AbstractAnnotationBeanPostProcessor.AnnotatedInjectionMetadata>(CACHE_SIZE);
private ConfigurableListableBeanFactory beanFactory; private ConfigurableListableBeanFactory beanFactory;
@ -98,7 +97,7 @@ public abstract class AbstractAnnotationBeanPostProcessor
} }
private static <T> Collection<T> combine(Collection<? extends T>... elements) { private static <T> Collection<T> combine(Collection<? extends T>... elements) {
List<T> allElements = new ArrayList<T>(); List<T> allElements = new ArrayList<>();
for (Collection<? extends T> e : elements) { for (Collection<? extends T> e : elements) {
allElements.addAll(e); allElements.addAll(e);
} }

View File

@ -87,7 +87,7 @@ public abstract class AnnotationUtils {
Set<String> ignoreAttributeNamesSet = new HashSet<>(Arrays.asList(ignoreAttributeNames)); Set<String> ignoreAttributeNamesSet = new HashSet<>(Arrays.asList(ignoreAttributeNames));
Map<String, Object> actualAttributes = new LinkedHashMap<String, Object>(); Map<String, Object> actualAttributes = new LinkedHashMap<>();
for (Map.Entry<String, Object> annotationAttribute : annotationAttributes.entrySet()) { for (Map.Entry<String, Object> annotationAttribute : annotationAttributes.entrySet()) {
@ -143,7 +143,7 @@ public abstract class AnnotationUtils {
if (ignoreDefaultValue && !isEmpty(annotationAttributes)) { if (ignoreDefaultValue && !isEmpty(annotationAttributes)) {
List<String> attributeNamesToIgnore = new LinkedList<String>(asList(ignoreAttributeNames)); List<String> attributeNamesToIgnore = new LinkedList<>(asList(ignoreAttributeNames));
for (Map.Entry<String, Object> annotationAttribute : annotationAttributes.entrySet()) { for (Map.Entry<String, Object> annotationAttribute : annotationAttributes.entrySet()) {
String attributeName = annotationAttribute.getKey(); String attributeName = annotationAttribute.getKey();

View File

@ -103,7 +103,7 @@ public abstract class PropertySourcesUtils {
public static Map<String, Object> getSubProperties( public static Map<String, Object> getSubProperties(
PropertySources propertySources, PropertyResolver propertyResolver, String prefix) { PropertySources propertySources, PropertyResolver propertyResolver, String prefix) {
Map<String, Object> subProperties = new LinkedHashMap<String, Object>(); Map<String, Object> subProperties = new LinkedHashMap<>();
String normalizedPrefix = normalizePrefix(prefix); String normalizedPrefix = normalizePrefix(prefix);

View File

@ -60,7 +60,7 @@ public class Main {
args = COMMA_SPLIT_PATTERN.split(config); args = COMMA_SPLIT_PATTERN.split(config);
} }
final List<Container> containers = new ArrayList<Container>(); final List<Container> containers = new ArrayList<>();
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
containers.add(LOADER.getExtension(args[i])); containers.add(LOADER.getExtension(args[i]));
} }

View File

@ -42,7 +42,7 @@ public abstract class AbstractCacheFactory implements CacheFactory {
/** /**
* This is used to store factory level-1 cached data. * This is used to store factory level-1 cached data.
*/ */
private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<String, Cache>(); private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<>();
private final Object MONITOR = new Object(); private final Object MONITOR = new Object();

View File

@ -158,7 +158,7 @@ public class ExpiringMap<K, V> implements Map<K, V> {
@Override @Override
public Collection<V> values() { public Collection<V> values() {
List<V> list = new ArrayList<V>(); List<V> list = new ArrayList<>();
Set<Entry<K, ExpiryObject>> delegatedSet = delegateMap.entrySet(); Set<Entry<K, ExpiryObject>> delegatedSet = delegateMap.entrySet();
for (Entry<K, ExpiryObject> entry : delegatedSet) { for (Entry<K, ExpiryObject> entry : delegatedSet) {
ExpiryObject value = entry.getValue(); ExpiryObject value = entry.getValue();

View File

@ -258,7 +258,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
if (StringUtils.isEmpty(content)) { if (StringUtils.isEmpty(content)) {
return Collections.emptyList(); return Collections.emptyList();
} }
return new ArrayList<String>(Arrays.asList(URL.decode(content))); return new ArrayList<>(Arrays.asList(URL.decode(content)));
} }
@Override @Override

View File

@ -53,9 +53,9 @@ public abstract class AbstractMonitorFactory implements MonitorFactory {
/** /**
* The monitor centers Map<RegistryAddress, Registry> * The monitor centers Map<RegistryAddress, Registry>
*/ */
private static final Map<String, Monitor> MONITORS = new ConcurrentHashMap<String, Monitor>(); private static final Map<String, Monitor> MONITORS = new ConcurrentHashMap<>();
private static final Map<String, Future<Monitor>> FUTURES = new ConcurrentHashMap<String, Future<Monitor>>(); private static final Map<String, Future<Monitor>> FUTURES = new ConcurrentHashMap<>();
/** /**
* The monitor create executor * The monitor create executor

View File

@ -46,7 +46,7 @@ public class HttpCommandDecoder {
commandContext = CommandContextFactory.newInstance(name); commandContext = CommandContextFactory.newInstance(name);
commandContext.setHttp(true); commandContext.setHttp(true);
} else { } else {
List<String> valueList = new ArrayList<String>(); List<String> valueList = new ArrayList<>();
for (List<String> values : for (List<String> values :
queryStringDecoder.parameters().values()) { queryStringDecoder.parameters().values()) {
valueList.addAll(values); valueList.addAll(values);
@ -56,7 +56,7 @@ public class HttpCommandDecoder {
} }
} else if (request.method() == HttpMethod.POST) { } else if (request.method() == HttpMethod.POST) {
HttpPostRequestDecoder httpPostRequestDecoder = new HttpPostRequestDecoder(request); HttpPostRequestDecoder httpPostRequestDecoder = new HttpPostRequestDecoder(request);
List<String> valueList = new ArrayList<String>(); List<String> valueList = new ArrayList<>();
for (InterfaceHttpData interfaceHttpData : httpPostRequestDecoder.getBodyHttpDatas()) { for (InterfaceHttpData interfaceHttpData : httpPostRequestDecoder.getBodyHttpDatas()) {
if (interfaceHttpData.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) { if (interfaceHttpData.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) {
Attribute attribute = (Attribute) interfaceHttpData; Attribute attribute = (Attribute) interfaceHttpData;

View File

@ -155,8 +155,8 @@ public class CountTelnet implements BaseCommand {
private String count(Invoker<?> invoker, String method) { private String count(Invoker<?> invoker, String method) {
URL url = invoker.getUrl(); URL url = invoker.getUrl();
List<List<String>> table = new ArrayList<List<String>>(); List<List<String>> table = new ArrayList<>();
List<String> header = new ArrayList<String>(); List<String> header = new ArrayList<>();
header.add("method"); header.add("method");
header.add("total"); header.add("total");
header.add("failed"); header.add("failed");
@ -188,7 +188,7 @@ public class CountTelnet implements BaseCommand {
} }
private List<String> createRow(String methodName, RpcStatus count) { private List<String> createRow(String methodName, RpcStatus count) {
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
row.add(methodName); row.add(methodName);
row.add(String.valueOf(count.getTotal())); row.add(String.valueOf(count.getTotal()));
row.add(String.valueOf(count.getFailed())); row.add(String.valueOf(count.getFailed()));

View File

@ -46,7 +46,7 @@ public class CommandHelper {
public List<Class<?>> getAllCommandClass() { public List<Class<?>> getAllCommandClass() {
final Set<String> commandList = final Set<String> commandList =
frameworkModel.getExtensionLoader(BaseCommand.class).getSupportedExtensions(); frameworkModel.getExtensionLoader(BaseCommand.class).getSupportedExtensions();
final List<Class<?>> classes = new ArrayList<Class<?>>(); final List<Class<?>> classes = new ArrayList<>();
for (String commandName : commandList) { for (String commandName : commandList) {
BaseCommand command = BaseCommand command =

View File

@ -35,7 +35,7 @@ public class TLadder implements TComponent {
// indent length // indent length
private static final int INDENT_STEP = 2; private static final int INDENT_STEP = 2;
private final List<String> items = new LinkedList<String>(); private final List<String> items = new LinkedList<>();
@Override @Override
public String rendering() { public String rendering() {

View File

@ -299,7 +299,7 @@ public class TTable implements TComponent {
private final Align align; private final Align align;
// data rows // data rows
private final List<String> rows = new ArrayList<String>(); private final List<String> rows = new ArrayList<>();
public ColumnDefine(int width, boolean isAutoResize, Align align) { public ColumnDefine(int width, boolean isAutoResize, Align align) {
this.width = width; this.width = width;

View File

@ -181,7 +181,7 @@ public class TTree implements TComponent {
/** /**
* child nodes * child nodes
*/ */
final List<Node> children = new ArrayList<Node>(); final List<Node> children = new ArrayList<>();
/** /**
* begin timestamp * begin timestamp

View File

@ -83,7 +83,7 @@ public final class ReactorServerCalls {
public static <T, R> StreamObserver<T> manyToOne( public static <T, R> StreamObserver<T> manyToOne(
StreamObserver<R> responseObserver, Function<Flux<T>, Mono<R>> func) { StreamObserver<R> responseObserver, Function<Flux<T>, Mono<R>> func) {
ServerTripleReactorPublisher<T> serverPublisher = ServerTripleReactorPublisher<T> serverPublisher =
new ServerTripleReactorPublisher<T>((CallStreamObserver<R>) responseObserver); new ServerTripleReactorPublisher<>((CallStreamObserver<R>) responseObserver);
try { try {
Mono<R> responseMono = func.apply(Flux.from(serverPublisher)); Mono<R> responseMono = func.apply(Flux.from(serverPublisher));
responseMono.subscribe( responseMono.subscribe(
@ -118,7 +118,7 @@ public final class ReactorServerCalls {
StreamObserver<R> responseObserver, Function<Flux<T>, Flux<R>> func) { StreamObserver<R> responseObserver, Function<Flux<T>, Flux<R>> func) {
// responseObserver is also a subscription of publisher, we can use it to request more data // responseObserver is also a subscription of publisher, we can use it to request more data
ServerTripleReactorPublisher<T> serverPublisher = ServerTripleReactorPublisher<T> serverPublisher =
new ServerTripleReactorPublisher<T>((CallStreamObserver<R>) responseObserver); new ServerTripleReactorPublisher<>((CallStreamObserver<R>) responseObserver);
try { try {
Flux<R> responseFlux = func.apply(Flux.from(serverPublisher)); Flux<R> responseFlux = func.apply(Flux.from(serverPublisher));
ServerTripleReactorSubscriber<R> serverSubscriber = ServerTripleReactorSubscriber<R> serverSubscriber =

View File

@ -75,6 +75,6 @@ public class InterfaceCompatibleRegistryProtocol extends RegistryProtocol {
URL url, URL url,
URL consumerUrl) { URL consumerUrl) {
// ClusterInvoker<T> invoker = getInvoker(cluster, registry, type, url); // ClusterInvoker<T> invoker = getInvoker(cluster, registry, type, url);
return new MigrationInvoker<T>(registryProtocol, cluster, registry, type, url, consumerUrl); return new MigrationInvoker<>(registryProtocol, cluster, registry, type, url, consumerUrl);
} }
} }

View File

@ -82,7 +82,7 @@ public class MulticastRegistry extends FailbackRegistry {
private final int multicastPort; private final int multicastPort;
private final ConcurrentMap<URL, Set<URL>> received = new ConcurrentHashMap<URL, Set<URL>>(); private final ConcurrentMap<URL, Set<URL>> received = new ConcurrentHashMap<>();
private final ScheduledExecutorService cleanExecutor = private final ScheduledExecutorService cleanExecutor =
Executors.newScheduledThreadPool(1, new NamedThreadFactory("DubboMulticastRegistryCleanTimer", true)); Executors.newScheduledThreadPool(1, new NamedThreadFactory("DubboMulticastRegistryCleanTimer", true));
@ -361,7 +361,7 @@ public class MulticastRegistry extends FailbackRegistry {
} }
if (urls == null || urls.isEmpty()) { if (urls == null || urls.isEmpty()) {
if (urls == null) { if (urls == null) {
urls = new ConcurrentHashSet<URL>(); urls = new ConcurrentHashSet<>();
} }
URL empty = url.setProtocol(EMPTY_PROTOCOL); URL empty = url.setProtocol(EMPTY_PROTOCOL);
urls.add(empty); urls.add(empty);
@ -380,7 +380,7 @@ public class MulticastRegistry extends FailbackRegistry {
} }
private List<URL> toList(Set<URL> urls) { private List<URL> toList(Set<URL> urls) {
List<URL> list = new ArrayList<URL>(); List<URL> list = new ArrayList<>();
if (CollectionUtils.isNotEmpty(urls)) { if (CollectionUtils.isNotEmpty(urls)) {
list.addAll(urls); list.addAll(urls);
} }

View File

@ -268,7 +268,7 @@ public class MultipleRegistry extends AbstractRegistry {
protected static class MultipleNotifyListenerWrapper implements NotifyListener { protected static class MultipleNotifyListenerWrapper implements NotifyListener {
Map<URL, SingleNotifyListener> registryMap = new ConcurrentHashMap<URL, SingleNotifyListener>(4); Map<URL, SingleNotifyListener> registryMap = new ConcurrentHashMap<>(4);
NotifyListener sourceNotifyListener; NotifyListener sourceNotifyListener;
public MultipleNotifyListenerWrapper(NotifyListener sourceNotifyListener) { public MultipleNotifyListenerWrapper(NotifyListener sourceNotifyListener) {

View File

@ -30,7 +30,7 @@ public class ReplierDispatcher implements Replier<Object> {
private final Replier<?> defaultReplier; private final Replier<?> defaultReplier;
private final Map<Class<?>, Replier<?>> repliers = new ConcurrentHashMap<Class<?>, Replier<?>>(); private final Map<Class<?>, Replier<?>> repliers = new ConcurrentHashMap<>();
public ReplierDispatcher() { public ReplierDispatcher() {
this(null, null); this(null, null);

View File

@ -161,7 +161,7 @@ public class HeaderExchangeServer implements ExchangeServer {
@Override @Override
public Collection<ExchangeChannel> getExchangeChannels() { public Collection<ExchangeChannel> getExchangeChannels() {
Collection<ExchangeChannel> exchangeChannels = new ArrayList<ExchangeChannel>(); Collection<ExchangeChannel> exchangeChannels = new ArrayList<>();
Collection<Channel> channels = server.getChannels(); Collection<Channel> channels = server.getChannels();
if (CollectionUtils.isNotEmpty(channels)) { if (CollectionUtils.isNotEmpty(channels)) {
for (Channel channel : channels) { for (Channel channel : channels) {

View File

@ -283,7 +283,7 @@ public class TelnetCodec extends TransportCodec {
String result = toString(message, getCharset(channel)); String result = toString(message, getCharset(channel));
if (result.trim().length() > 0) { if (result.trim().length() > 0) {
if (history == null) { if (history == null) {
history = new LinkedList<String>(); history = new LinkedList<>();
channel.setAttribute(HISTORY_LIST_KEY, history); channel.setAttribute(HISTORY_LIST_KEY, history);
} }
if (history.isEmpty()) { if (history.isEmpty()) {

View File

@ -73,12 +73,12 @@ public class HelpTelnetHandler implements TelnetHandler {
} }
private String generateForAllCommand(Channel channel) { private String generateForAllCommand(Channel channel) {
List<List<String>> table = new ArrayList<List<String>>(); List<List<String>> table = new ArrayList<>();
List<TelnetHandler> handlers = extensionLoader.getActivateExtension(channel.getUrl(), "telnet"); List<TelnetHandler> handlers = extensionLoader.getActivateExtension(channel.getUrl(), "telnet");
if (CollectionUtils.isNotEmpty(handlers)) { if (CollectionUtils.isNotEmpty(handlers)) {
for (TelnetHandler handler : handlers) { for (TelnetHandler handler : handlers) {
Help help = handler.getClass().getAnnotation(Help.class); Help help = handler.getClass().getAnnotation(Help.class);
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
String parameter = " " + extensionLoader.getExtensionName(handler) + " " String parameter = " " + extensionLoader.getExtensionName(handler) + " "
+ (help != null ? help.parameter().replace("\r\n", " ").replace("\n", " ") : ""); + (help != null ? help.parameter().replace("\r\n", " ").replace("\n", " ") : "");
row.add(parameter.length() > 55 ? parameter.substring(0, 55) + "..." : parameter); row.add(parameter.length() > 55 ? parameter.substring(0, 55) + "..." : parameter);

View File

@ -53,8 +53,8 @@ public class StatusTelnetHandler implements TelnetHandler {
if ("-l".equals(message)) { if ("-l".equals(message)) {
List<StatusChecker> checkers = extensionLoader.getActivateExtension(channel.getUrl(), STATUS_KEY); List<StatusChecker> checkers = extensionLoader.getActivateExtension(channel.getUrl(), STATUS_KEY);
String[] header = new String[] {"resource", "status", "message"}; String[] header = new String[] {"resource", "status", "message"};
List<List<String>> table = new ArrayList<List<String>>(); List<List<String>> table = new ArrayList<>();
Map<String, Status> statuses = new HashMap<String, Status>(); Map<String, Status> statuses = new HashMap<>();
if (CollectionUtils.isNotEmpty(checkers)) { if (CollectionUtils.isNotEmpty(checkers)) {
for (StatusChecker checker : checkers) { for (StatusChecker checker : checkers) {
String name = extensionLoader.getExtensionName(checker); String name = extensionLoader.getExtensionName(checker);
@ -66,7 +66,7 @@ public class StatusTelnetHandler implements TelnetHandler {
} }
statuses.put(name, stat); statuses.put(name, stat);
if (stat.getLevel() != null && stat.getLevel() != Status.Level.UNKNOWN) { if (stat.getLevel() != null && stat.getLevel() != Status.Level.UNKNOWN) {
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
row.add(name); row.add(name);
row.add(String.valueOf(stat.getLevel())); row.add(String.valueOf(stat.getLevel()));
row.add(stat.getMessage() == null ? "" : stat.getMessage()); row.add(stat.getMessage() == null ? "" : stat.getMessage());
@ -75,7 +75,7 @@ public class StatusTelnetHandler implements TelnetHandler {
} }
} }
Status stat = StatusUtils.getSummaryStatus(statuses); Status stat = StatusUtils.getSummaryStatus(statuses);
List<String> row = new ArrayList<String>(); List<String> row = new ArrayList<>();
row.add("summary"); row.add("summary");
row.add(String.valueOf(stat.getLevel())); row.add(String.valueOf(stat.getLevel()));
row.add(stat.getMessage()); row.add(stat.getMessage());
@ -85,7 +85,7 @@ public class StatusTelnetHandler implements TelnetHandler {
return "Unsupported parameter " + message + " for status."; return "Unsupported parameter " + message + " for status.";
} }
String status = channel.getUrl().getParameter("status"); String status = channel.getUrl().getParameter("status");
Map<String, Status> statuses = new HashMap<String, Status>(); Map<String, Status> statuses = new HashMap<>();
if (StringUtils.isNotEmpty(status)) { if (StringUtils.isNotEmpty(status)) {
String[] ss = COMMA_SPLIT_PATTERN.split(status); String[] ss = COMMA_SPLIT_PATTERN.split(status);
for (String s : ss) { for (String s : ss) {

View File

@ -42,9 +42,9 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FA
public class CodecSupport { public class CodecSupport {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CodecSupport.class); private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CodecSupport.class);
private static Map<Byte, Serialization> ID_SERIALIZATION_MAP = new HashMap<Byte, Serialization>(); private static Map<Byte, Serialization> ID_SERIALIZATION_MAP = new HashMap<>();
private static Map<Byte, String> ID_SERIALIZATIONNAME_MAP = new HashMap<Byte, String>(); private static Map<Byte, String> ID_SERIALIZATIONNAME_MAP = new HashMap<>();
private static Map<String, Byte> SERIALIZATIONNAME_ID_MAP = new HashMap<String, Byte>(); private static Map<String, Byte> SERIALIZATIONNAME_ID_MAP = new HashMap<>();
// Cache null object serialize results, for heartbeat request/response serialize use. // Cache null object serialize results, for heartbeat request/response serialize use.
private static ConcurrentMap<Byte, byte[]> ID_NULLBYTES_MAP = new ConcurrentHashMap<>(); private static ConcurrentMap<Byte, byte[]> ID_NULLBYTES_MAP = new ConcurrentHashMap<>();

View File

@ -35,8 +35,8 @@ public class RequestTemplate implements Serializable {
public static final String ENCODING_DEFLATE = "deflate"; public static final String ENCODING_DEFLATE = "deflate";
private static final List<String> EMPTY_ARRAYLIST = new ArrayList<>(); private static final List<String> EMPTY_ARRAYLIST = new ArrayList<>();
private final Map<String, Collection<String>> queries = new LinkedHashMap<String, Collection<String>>(); private final Map<String, Collection<String>> queries = new LinkedHashMap<>();
private final Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>(); private final Map<String, Collection<String>> headers = new LinkedHashMap<>();
private String httpMethod; private String httpMethod;
private String path; private String path;
private String address; private String address;

View File

@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class DispatcherServlet extends HttpServlet { public class DispatcherServlet extends HttpServlet {
private static final long serialVersionUID = 5766349180380479888L; private static final long serialVersionUID = 5766349180380479888L;
private static final Map<Integer, HttpHandler> HANDLERS = new ConcurrentHashMap<Integer, HttpHandler>(); private static final Map<Integer, HttpHandler> HANDLERS = new ConcurrentHashMap<>();
private static DispatcherServlet INSTANCE; private static DispatcherServlet INSTANCE;
public DispatcherServlet() { public DispatcherServlet() {

View File

@ -30,7 +30,7 @@ public class ServletManager {
private static final ServletManager INSTANCE = new ServletManager(); private static final ServletManager INSTANCE = new ServletManager();
private final Map<Integer, ServletContext> contextMap = new ConcurrentHashMap<Integer, ServletContext>(); private final Map<Integer, ServletContext> contextMap = new ConcurrentHashMap<>();
public static ServletManager getInstance() { public static ServletManager getInstance() {
return INSTANCE; return INSTANCE;

View File

@ -43,11 +43,11 @@ final class NettyChannel extends AbstractChannel {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(NettyChannel.class); private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(NettyChannel.class);
private static final ConcurrentMap<org.jboss.netty.channel.Channel, NettyChannel> CHANNEL_MAP = private static final ConcurrentMap<org.jboss.netty.channel.Channel, NettyChannel> CHANNEL_MAP =
new ConcurrentHashMap<org.jboss.netty.channel.Channel, NettyChannel>(); new ConcurrentHashMap<>();
private final org.jboss.netty.channel.Channel channel; private final org.jboss.netty.channel.Channel channel;
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>(); private final Map<String, Object> attributes = new ConcurrentHashMap<>();
private NettyChannel(org.jboss.netty.channel.Channel channel, URL url, ChannelHandler handler) { private NettyChannel(org.jboss.netty.channel.Channel channel, URL url, ChannelHandler handler) {
super(url, handler); super(url, handler);

View File

@ -42,7 +42,7 @@ public class NettyHandler extends SimpleChannelHandler {
private static final Logger logger = LoggerFactory.getLogger(NettyHandler.class); private static final Logger logger = LoggerFactory.getLogger(NettyHandler.class);
private final Map<String, Channel> channels = new ConcurrentHashMap<String, Channel>(); // <ip:port, channel> private final Map<String, Channel> channels = new ConcurrentHashMap<>(); // <ip:port, channel>
private final URL url; private final URL url;

View File

@ -61,14 +61,13 @@ final class NettyChannel extends AbstractChannel {
/** /**
* the cache for netty channel and dubbo channel * the cache for netty channel and dubbo channel
*/ */
private static final ConcurrentMap<Channel, NettyChannel> CHANNEL_MAP = private static final ConcurrentMap<Channel, NettyChannel> CHANNEL_MAP = new ConcurrentHashMap<>();
new ConcurrentHashMap<Channel, NettyChannel>();
/** /**
* netty channel * netty channel
*/ */
private final Channel channel; private final Channel channel;
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>(); private final Map<String, Object> attributes = new ConcurrentHashMap<>();
private final AtomicBoolean active = new AtomicBoolean(false); private final AtomicBoolean active = new AtomicBoolean(false);

View File

@ -459,7 +459,7 @@ public class RpcServiceContext extends RpcContext {
public RpcServiceContext setInvokers(List<Invoker<?>> invokers) { public RpcServiceContext setInvokers(List<Invoker<?>> invokers) {
this.invokers = invokers; this.invokers = invokers;
if (CollectionUtils.isNotEmpty(invokers)) { if (CollectionUtils.isNotEmpty(invokers)) {
List<URL> urls = new ArrayList<URL>(invokers.size()); List<URL> urls = new ArrayList<>(invokers.size());
for (Invoker<?> invoker : invokers) { for (Invoker<?> invoker : invokers) {
urls.add(invoker.getUrl()); urls.add(invoker.getUrl());
} }

View File

@ -33,13 +33,12 @@ import java.util.concurrent.atomic.AtomicLong;
*/ */
public class RpcStatus { public class RpcStatus {
private static final ConcurrentMap<String, RpcStatus> SERVICE_STATISTICS = private static final ConcurrentMap<String, RpcStatus> SERVICE_STATISTICS = new ConcurrentHashMap<>();
new ConcurrentHashMap<String, RpcStatus>();
private static final ConcurrentMap<String, ConcurrentMap<String, RpcStatus>> METHOD_STATISTICS = private static final ConcurrentMap<String, ConcurrentMap<String, RpcStatus>> METHOD_STATISTICS =
new ConcurrentHashMap<String, ConcurrentMap<String, RpcStatus>>(); new ConcurrentHashMap<>();
private final ConcurrentMap<String, Object> values = new ConcurrentHashMap<String, Object>(); private final ConcurrentMap<String, Object> values = new ConcurrentHashMap<>();
private final AtomicInteger active = new AtomicInteger(); private final AtomicInteger active = new AtomicInteger();
private final AtomicLong total = new AtomicLong(); private final AtomicLong total = new AtomicLong();

View File

@ -44,7 +44,7 @@ public class DeprecatedFilter implements Filter {
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(DeprecatedFilter.class); private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(DeprecatedFilter.class);
private static final Set<String> LOGGED = new ConcurrentHashSet<String>(); private static final Set<String> LOGGED = new ConcurrentHashSet<>();
@Override @Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {

View File

@ -35,7 +35,7 @@ import static org.apache.dubbo.rpc.Constants.TPS_LIMIT_RATE_KEY;
*/ */
public class DefaultTPSLimiter implements TPSLimiter { public class DefaultTPSLimiter implements TPSLimiter {
private final ConcurrentMap<String, StatItem> stats = new ConcurrentHashMap<String, StatItem>(); private final ConcurrentMap<String, StatItem> stats = new ConcurrentHashMap<>();
@Override @Override
public boolean isAllowable(URL url, Invocation invocation) { public boolean isAllowable(URL url, Invocation invocation) {

View File

@ -50,7 +50,7 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_UNS
*/ */
public abstract class AbstractProxyProtocol extends AbstractProtocol { public abstract class AbstractProxyProtocol extends AbstractProtocol {
private final List<Class<?>> rpcExceptions = new CopyOnWriteArrayList<Class<?>>(); private final List<Class<?>> rpcExceptions = new CopyOnWriteArrayList<>();
protected ProxyFactory proxyFactory; protected ProxyFactory proxyFactory;

View File

@ -74,8 +74,7 @@ public class ProtocolListenerWrapper implements Protocol {
.getBeanFactory() .getBeanFactory()
.getBean(InjvmExporterListener.class)); .getBean(InjvmExporterListener.class));
} }
return new ListenerExporterWrapper<T>( return new ListenerExporterWrapper<>(protocol.export(invoker), Collections.unmodifiableList(exporterListeners));
protocol.export(invoker), Collections.unmodifiableList(exporterListeners));
} }
@Override @Override

View File

@ -47,8 +47,8 @@ import static org.apache.dubbo.rpc.Constants.THROW_PREFIX;
public final class MockInvoker<T> implements Invoker<T> { public final class MockInvoker<T> implements Invoker<T> {
private final ProxyFactory proxyFactory; private final ProxyFactory proxyFactory;
private static final Map<String, Invoker<?>> MOCK_MAP = new ConcurrentHashMap<String, Invoker<?>>(); private static final Map<String, Invoker<?>> MOCK_MAP = new ConcurrentHashMap<>();
private static final Map<String, Throwable> THROWABLE_MAP = new ConcurrentHashMap<String, Throwable>(); private static final Map<String, Throwable> THROWABLE_MAP = new ConcurrentHashMap<>();
private final URL url; private final URL url;
private final Class<T> type; private final Class<T> type;

View File

@ -339,7 +339,7 @@ public class DubboProtocol extends AbstractProtocol {
// export service. // export service.
String key = serviceKey(url); String key = serviceKey(url);
DubboExporter<T> exporter = new DubboExporter<T>(invoker, key, exporterMap); DubboExporter<T> exporter = new DubboExporter<>(invoker, key, exporterMap);
// export a stub service for dispatching event // export a stub service for dispatching event
boolean isStubSupportEvent = url.getParameter(STUB_EVENT_KEY, DEFAULT_STUB_EVENT); boolean isStubSupportEvent = url.getParameter(STUB_EVENT_KEY, DEFAULT_STUB_EVENT);
@ -443,7 +443,7 @@ public class DubboProtocol extends AbstractProtocol {
optimizeSerialization(url); optimizeSerialization(url);
// create rpc invoker. // create rpc invoker.
DubboInvoker<T> invoker = new DubboInvoker<T>(serviceType, url, getClients(url), invokers); DubboInvoker<T> invoker = new DubboInvoker<>(serviceType, url, getClients(url), invokers);
invokers.add(invoker); invokers.add(invoker);
return invoker; return invoker;

View File

@ -75,12 +75,12 @@ public class InjvmProtocol extends AbstractProtocol {
@Override @Override
public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException { public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
return new InjvmExporter<T>(invoker, invoker.getUrl().getServiceKey(), exporterMap); return new InjvmExporter<>(invoker, invoker.getUrl().getServiceKey(), exporterMap);
} }
@Override @Override
public <T> Invoker<T> protocolBindingRefer(Class<T> serviceType, URL url) throws RpcException { public <T> Invoker<T> protocolBindingRefer(Class<T> serviceType, URL url) throws RpcException {
return new InjvmInvoker<T>(serviceType, url, url.getServiceKey(), exporterMap); return new InjvmInvoker<>(serviceType, url, url.getServiceKey(), exporterMap);
} }
public boolean isInjvmRefer(URL url) { public boolean isInjvmRefer(URL url) {

View File

@ -134,7 +134,7 @@ public class RestProtocol extends AbstractProtocol {
MetadataResolver.resolveConsumerServiceMetadata(type, url, contextPathFromUrl); MetadataResolver.resolveConsumerServiceMetadata(type, url, contextPathFromUrl);
Invoker<T> invoker = Invoker<T> invoker =
new RestInvoker<T>(type, url, refClient, httpConnectionPreBuildIntercepts, serviceRestMetadata); new RestInvoker<>(type, url, refClient, httpConnectionPreBuildIntercepts, serviceRestMetadata);
invokers.add(invoker); invokers.add(invoker);
return invoker; return invoker;

View File

@ -42,7 +42,7 @@ public class ViolationReport implements Serializable {
public void addConstraintViolation(RestConstraintViolation constraintViolation) { public void addConstraintViolation(RestConstraintViolation constraintViolation) {
if (constraintViolations == null) { if (constraintViolations == null) {
constraintViolations = new LinkedList<RestConstraintViolation>(); constraintViolations = new LinkedList<>();
} }
constraintViolations.add(constraintViolation); constraintViolations.add(constraintViolation);
} }

View File

@ -82,7 +82,7 @@ public class DubboPreMatchContainerRequestContext implements SuspendableContaine
@Override @Override
public Collection<String> getPropertyNames() { public Collection<String> getPropertyNames() {
ArrayList<String> names = new ArrayList<String>(); ArrayList<String> names = new ArrayList<>();
Enumeration<String> enames = httpRequest.getAttributeNames(); Enumeration<String> enames = httpRequest.getAttributeNames();
while (enames.hasMoreElements()) { while (enames.hasMoreElements()) {
names.add(enames.nextElement()); names.add(enames.nextElement());

View File

@ -115,7 +115,7 @@ public class ReflectUtils {
} catch (Exception e) { } catch (Exception e) {
} }
return new ArrayList<Constructor<?>>(methods); return new ArrayList<>(methods);
} }
private static void filterConstructMethod(Set<Constructor<?>> methods, Constructor<?>[] declaredMethods) { private static void filterConstructMethod(Set<Constructor<?>> methods, Constructor<?>[] declaredMethods) {

View File

@ -306,7 +306,7 @@ public class TriHttp2RemoteFlowController implements Http2RemoteFlowController {
FlowState(Http2Stream stream) { FlowState(Http2Stream stream) {
this.stream = stream; this.stream = stream;
pendingWriteQueue = new ArrayDeque<FlowControlled>(2); pendingWriteQueue = new ArrayDeque<>(2);
} }
/** /**

View File

@ -24,7 +24,7 @@ import java.util.Map;
*/ */
public class SysProps { public class SysProps {
private static Map<String, String> map = new LinkedHashMap<String, String>(); private static Map<String, String> map = new LinkedHashMap<>();
public static void reset() { public static void reset() {
map.clear(); map.clear();