Collection.isEmpty() should be used to test for emptiness (#1315)
This commit is contained in:
parent
d388735548
commit
d129f10229
|
|
@ -72,7 +72,7 @@ public abstract class AbstractDirectory<T> implements Directory<T> {
|
|||
}
|
||||
List<Invoker<T>> invokers = doList(invocation);
|
||||
List<Router> localRouters = this.routers; // local reference
|
||||
if (localRouters != null && localRouters.size() > 0) {
|
||||
if (localRouters != null && !localRouters.isEmpty()) {
|
||||
for (Router router : localRouters) {
|
||||
try {
|
||||
if (router.getUrl() == null || router.getUrl().getParameter(Constants.RUNTIME_KEY, false)) {
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ public class StaticDirectory<T> extends AbstractDirectory<T> {
|
|||
}
|
||||
|
||||
public StaticDirectory(URL url, List<Invoker<T>> invokers, List<Router> routers) {
|
||||
super(url == null && invokers != null && invokers.size() > 0 ? invokers.get(0).getUrl() : url, routers);
|
||||
if (invokers == null || invokers.size() == 0)
|
||||
super(url == null && invokers != null && !invokers.isEmpty() ? invokers.get(0).getUrl() : url, routers);
|
||||
if (invokers == null || invokers.isEmpty())
|
||||
throw new IllegalArgumentException("invokers == null");
|
||||
this.invokers = invokers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public abstract class AbstractLoadBalance implements LoadBalance {
|
|||
}
|
||||
|
||||
public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation) {
|
||||
if (invokers == null || invokers.size() == 0)
|
||||
if (invokers == null || invokers.isEmpty())
|
||||
return null;
|
||||
if (invokers.size() == 1)
|
||||
return invokers.get(0);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
}
|
||||
// The Value in the KV part, if Value have more than one items.
|
||||
else if (",".equals(separator)) { // Should be seperateed by ','
|
||||
if (values == null || values.size() == 0)
|
||||
if (values == null || values.isEmpty())
|
||||
throw new ParseException("Illegal route rule \""
|
||||
+ rule + "\", The error char '" + separator
|
||||
+ "' at index " + matcher.start() + " before \""
|
||||
|
|
@ -144,7 +144,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
|
||||
public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation)
|
||||
throws RpcException {
|
||||
if (invokers == null || invokers.size() == 0) {
|
||||
if (invokers == null || invokers.isEmpty()) {
|
||||
return invokers;
|
||||
}
|
||||
try {
|
||||
|
|
@ -161,7 +161,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
result.add(invoker);
|
||||
}
|
||||
}
|
||||
if (result.size() > 0) {
|
||||
if (!result.isEmpty()) {
|
||||
return result;
|
||||
} else if (force) {
|
||||
logger.warn("The route result is empty and force execute. consumer: " + NetUtils.getLocalHost() + ", service: " + url.getServiceKey() + ", router: " + url.getParameterAndDecoded(Constants.RULE_KEY));
|
||||
|
|
@ -216,7 +216,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
}
|
||||
} else {
|
||||
//not pass the condition
|
||||
if (matchPair.getValue().matches.size() > 0) {
|
||||
if (!matchPair.getValue().matches.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
result = true;
|
||||
|
|
@ -231,7 +231,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
final Set<String> mismatches = new HashSet<String>();
|
||||
|
||||
private boolean isMatch(String value, URL param) {
|
||||
if (matches.size() > 0 && mismatches.size() == 0) {
|
||||
if (!matches.isEmpty() && mismatches.isEmpty()) {
|
||||
for (String match : matches) {
|
||||
if (UrlUtils.isMatchGlobPattern(match, value, param)) {
|
||||
return true;
|
||||
|
|
@ -240,7 +240,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mismatches.size() > 0 && matches.size() == 0) {
|
||||
if (!mismatches.isEmpty() && matches.isEmpty()) {
|
||||
for (String mismatch : mismatches) {
|
||||
if (UrlUtils.isMatchGlobPattern(mismatch, value, param)) {
|
||||
return false;
|
||||
|
|
@ -249,7 +249,7 @@ public class ConditionRouter implements Router, Comparable<Router> {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (matches.size() > 0 && mismatches.size() > 0) {
|
||||
if (!matches.isEmpty() && !mismatches.isEmpty()) {
|
||||
//when both mismatches and matches contain the same value, then using mismatches first
|
||||
for (String mismatch : mismatches) {
|
||||
if (UrlUtils.isMatchGlobPattern(mismatch, value, param)) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
* @throws RpcExceptione
|
||||
*/
|
||||
protected Invoker<T> select(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
|
||||
if (invokers == null || invokers.size() == 0)
|
||||
if (invokers == null || invokers.isEmpty())
|
||||
return null;
|
||||
String methodName = invocation == null ? "" : invocation.getMethodName();
|
||||
|
||||
|
|
@ -125,12 +125,12 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
}
|
||||
|
||||
private Invoker<T> doselect(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
|
||||
if (invokers == null || invokers.size() == 0)
|
||||
if (invokers == null || invokers.isEmpty())
|
||||
return null;
|
||||
if (invokers.size() == 1)
|
||||
return invokers.get(0);
|
||||
// If we only have two invokers, use round-robin instead.
|
||||
if (invokers.size() == 2 && selected != null && selected.size() > 0) {
|
||||
if (invokers.size() == 2 && selected != null && !selected.isEmpty()) {
|
||||
return selected.get(0) == invokers.get(0) ? invokers.get(1) : invokers.get(0);
|
||||
}
|
||||
Invoker<T> invoker = loadbalance.select(invokers, getUrl(), invocation);
|
||||
|
|
@ -185,7 +185,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (reselectInvokers.size() > 0) {
|
||||
if (!reselectInvokers.isEmpty()) {
|
||||
return loadbalance.select(reselectInvokers, getUrl(), invocation);
|
||||
}
|
||||
} else { // do not check invoker.isAvailable()
|
||||
|
|
@ -194,7 +194,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
reselectInvokers.add(invoker);
|
||||
}
|
||||
}
|
||||
if (reselectInvokers.size() > 0) {
|
||||
if (!reselectInvokers.isEmpty()) {
|
||||
return loadbalance.select(reselectInvokers, getUrl(), invocation);
|
||||
}
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (reselectInvokers.size() > 0) {
|
||||
if (!reselectInvokers.isEmpty()) {
|
||||
return loadbalance.select(reselectInvokers, getUrl(), invocation);
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
LoadBalance loadbalance;
|
||||
|
||||
List<Invoker<T>> invokers = list(invocation);
|
||||
if (invokers != null && invokers.size() > 0) {
|
||||
if (invokers != null && !invokers.isEmpty()) {
|
||||
loadbalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(invokers.get(0).getUrl()
|
||||
.getMethodParameter(invocation.getMethodName(), Constants.LOADBALANCE_KEY, Constants.DEFAULT_LOADBALANCE));
|
||||
} else {
|
||||
|
|
@ -247,7 +247,7 @@ public abstract class AbstractClusterInvoker<T> implements Invoker<T> {
|
|||
}
|
||||
|
||||
protected void checkInvokers(List<Invoker<T>> invokers, Invocation invocation) {
|
||||
if (invokers == null || invokers.size() == 0) {
|
||||
if (invokers == null || invokers.isEmpty()) {
|
||||
throw new RpcException("Failed to invoke the method "
|
||||
+ invocation.getMethodName() + " in the service " + getInterface().getName()
|
||||
+ ". No provider available for the service " + directory.getUrl().getServiceKey()
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class MergeableClusterInvoker<T> implements Invoker<T> {
|
|||
}
|
||||
}
|
||||
|
||||
if (resultList.size() == 0) {
|
||||
if (resultList.isEmpty()) {
|
||||
return new RpcResult((Object) null);
|
||||
} else if (resultList.size() == 1) {
|
||||
return resultList.iterator().next();
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class MockClusterInvoker<T> implements Invoker<T> {
|
|||
Invoker<T> minvoker;
|
||||
|
||||
List<Invoker<T>> mockInvokers = selectMockInvoker(invocation);
|
||||
if (mockInvokers == null || mockInvokers.size() == 0) {
|
||||
if (mockInvokers == null || mockInvokers.isEmpty()) {
|
||||
minvoker = (Invoker<T>) new MockInvoker(directory.getUrl());
|
||||
} else {
|
||||
minvoker = mockInvokers.get(0);
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ public final class URL implements Serializable {
|
|||
}
|
||||
|
||||
public URL removeParameters(Collection<String> keys) {
|
||||
if (keys == null || keys.size() == 0) {
|
||||
if (keys == null || keys.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
return removeParameters(keys.toArray(new String[0]));
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ public class ExtensionLoader<T> {
|
|||
if (!name.startsWith(Constants.REMOVE_VALUE_PREFIX)
|
||||
&& !names.contains(Constants.REMOVE_VALUE_PREFIX + name)) {
|
||||
if (Constants.DEFAULT_KEY.equals(name)) {
|
||||
if (usrs.size() > 0) {
|
||||
if (!usrs.isEmpty()) {
|
||||
exts.addAll(0, usrs);
|
||||
usrs.clear();
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ public class ExtensionLoader<T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (usrs.size() > 0) {
|
||||
if (!usrs.isEmpty()) {
|
||||
exts.addAll(usrs);
|
||||
}
|
||||
return exts;
|
||||
|
|
@ -495,7 +495,7 @@ public class ExtensionLoader<T> {
|
|||
}
|
||||
injectExtension(instance);
|
||||
Set<Class<?>> wrapperClasses = cachedWrapperClasses;
|
||||
if (wrapperClasses != null && wrapperClasses.size() > 0) {
|
||||
if (wrapperClasses != null && !wrapperClasses.isEmpty()) {
|
||||
for (Class<?> wrapperClass : wrapperClasses) {
|
||||
instance = injectExtension((T) wrapperClass.getConstructor(type).newInstance(instance));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class SpiExtensionFactory implements ExtensionFactory {
|
|||
public <T> T getExtension(Class<T> type, String name) {
|
||||
if (type.isInterface() && type.isAnnotationPresent(SPI.class)) {
|
||||
ExtensionLoader<T> loader = ExtensionLoader.getExtensionLoader(type);
|
||||
if (loader.getSupportedExtensions().size() > 0) {
|
||||
if (!loader.getSupportedExtensions().isEmpty()) {
|
||||
return loader.getAdaptiveExtension();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class CollectionUtils {
|
|||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T> List<T> sort(List<T> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
if (list != null && !list.isEmpty()) {
|
||||
Collections.sort((List) list);
|
||||
}
|
||||
return list;
|
||||
|
|
@ -94,7 +94,7 @@ public class CollectionUtils {
|
|||
return null;
|
||||
}
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
if (list == null || list.size() == 0) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
for (String item : list) {
|
||||
|
|
@ -199,11 +199,11 @@ public class CollectionUtils {
|
|||
}
|
||||
|
||||
public static boolean isEmpty(Collection<?> collection) {
|
||||
return collection == null || collection.size() == 0;
|
||||
return collection == null || collection.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Collection<?> collection) {
|
||||
return collection != null && collection.size() > 0;
|
||||
return collection != null && !collection.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ public class ConfigUtils {
|
|||
logger.warn("Fail to load " + fileName + " file: " + t.getMessage(), t);
|
||||
}
|
||||
|
||||
if (list.size() == 0) {
|
||||
if (list.isEmpty()) {
|
||||
if (!optional) {
|
||||
logger.warn("No " + fileName + " found on the class path.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ public class UrlUtils {
|
|||
|
||||
//compatible for dubbo-2.0.0
|
||||
public static List<String> revertForbid(List<String> forbid, Set<URL> subscribed) {
|
||||
if (forbid != null && forbid.size() > 0) {
|
||||
if (forbid != null && !forbid.isEmpty()) {
|
||||
List<String> newForbid = new ArrayList<String>();
|
||||
for (String serviceName : forbid) {
|
||||
if (!serviceName.contains(":") && !serviceName.contains("/")) {
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
|
||||
protected void checkRegistry() {
|
||||
// for backward compatibility
|
||||
if (registries == null || registries.size() == 0) {
|
||||
if (registries == null || registries.isEmpty()) {
|
||||
String address = ConfigUtils.getProperty("dubbo.registry.address");
|
||||
if (address != null && address.length() > 0) {
|
||||
registries = new ArrayList<RegistryConfig>();
|
||||
|
|
@ -116,7 +116,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((registries == null || registries.size() == 0)) {
|
||||
if ((registries == null || registries.isEmpty())) {
|
||||
throw new IllegalStateException((getClass().getSimpleName().startsWith("Reference")
|
||||
? "No such any registry to refer service in consumer "
|
||||
: "No such any registry to export service in provider ")
|
||||
|
|
@ -159,7 +159,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
protected List<URL> loadRegistries(boolean provider) {
|
||||
checkRegistry();
|
||||
List<URL> registryList = new ArrayList<URL>();
|
||||
if (registries != null && registries.size() > 0) {
|
||||
if (registries != null && !registries.isEmpty()) {
|
||||
for (RegistryConfig config : registries) {
|
||||
String address = config.getAddress();
|
||||
if (address == null || address.length() == 0) {
|
||||
|
|
@ -257,7 +257,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
throw new IllegalStateException("The interface class " + interfaceClass + " is not a interface!");
|
||||
}
|
||||
// check if methods exist in the interface
|
||||
if (methods != null && methods.size() > 0) {
|
||||
if (methods != null && !methods.isEmpty()) {
|
||||
for (MethodConfig methodBean : methods) {
|
||||
String methodName = methodBean.getName();
|
||||
if (methodName == null || methodName.length() == 0) {
|
||||
|
|
@ -444,7 +444,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
|
||||
public RegistryConfig getRegistry() {
|
||||
return registries == null || registries.size() == 0 ? null : registries.get(0);
|
||||
return registries == null || registries.isEmpty() ? null : registries.get(0);
|
||||
}
|
||||
|
||||
public void setRegistry(RegistryConfig registry) {
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig {
|
|||
}
|
||||
|
||||
public ProtocolConfig getProtocol() {
|
||||
return protocols == null || protocols.size() == 0 ? null : protocols.get(0);
|
||||
return protocols == null || protocols.isEmpty() ? null : protocols.get(0);
|
||||
}
|
||||
|
||||
public void setProtocol(ProtocolConfig protocol) {
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public RegistryConfig getRegistry() {
|
||||
return registries == null || registries.size() == 0 ? null : registries.get(0);
|
||||
return registries == null || registries.isEmpty() ? null : registries.get(0);
|
||||
}
|
||||
|
||||
public void setRegistry(RegistryConfig registry) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class ModuleConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public RegistryConfig getRegistry() {
|
||||
return registries == null || registries.size() == 0 ? null : registries.get(0);
|
||||
return registries == null || registries.isEmpty() ? null : registries.get(0);
|
||||
}
|
||||
|
||||
public void setRegistry(RegistryConfig registry) {
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
}
|
||||
|
||||
public URL toUrl() {
|
||||
return urls == null || urls.size() == 0 ? null : urls.iterator().next();
|
||||
return urls == null || urls.isEmpty() ? null : urls.iterator().next();
|
||||
}
|
||||
|
||||
public List<URL> toUrls() {
|
||||
|
|
@ -305,7 +305,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
appendParameters(map, consumer, Constants.DEFAULT_KEY);
|
||||
appendParameters(map, this);
|
||||
String prefix = StringUtils.getServiceKey(map);
|
||||
if (methods != null && methods.size() > 0) {
|
||||
if (methods != null && !methods.isEmpty()) {
|
||||
for (MethodConfig method : methods) {
|
||||
appendParameters(map, method, method.getName());
|
||||
String retryKey = method.getName() + ".retry";
|
||||
|
|
@ -376,7 +376,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
}
|
||||
} else { // assemble URL from register center's configuration
|
||||
List<URL> us = loadRegistries(false);
|
||||
if (us != null && us.size() > 0) {
|
||||
if (us != null && !us.isEmpty()) {
|
||||
for (URL u : us) {
|
||||
URL monitorUrl = loadMonitor(u);
|
||||
if (monitorUrl != null) {
|
||||
|
|
@ -385,7 +385,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
urls.add(u.addParameterAndEncoded(Constants.REFER_KEY, StringUtils.toQueryString(map)));
|
||||
}
|
||||
}
|
||||
if (urls == null || urls.size() == 0) {
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
throw new IllegalStateException("No such any registry to reference " + interfaceName + " on the consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion() + ", please config <dubbo:registry address=\"...\" /> to your spring config.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
|
||||
@Deprecated
|
||||
private static final List<ProtocolConfig> convertProviderToProtocol(List<ProviderConfig> providers) {
|
||||
if (providers == null || providers.size() == 0) {
|
||||
if (providers == null || providers.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<ProtocolConfig> protocols = new ArrayList<ProtocolConfig>(providers.size());
|
||||
|
|
@ -117,7 +117,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
|
||||
@Deprecated
|
||||
private static final List<ProviderConfig> convertProtocolToProvider(List<ProtocolConfig> protocols) {
|
||||
if (protocols == null || protocols.size() == 0) {
|
||||
if (protocols == null || protocols.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<ProviderConfig> providers = new ArrayList<ProviderConfig>(protocols.size());
|
||||
|
|
@ -175,7 +175,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
}
|
||||
|
||||
public URL toUrl() {
|
||||
return urls == null || urls.size() == 0 ? null : urls.iterator().next();
|
||||
return urls == null || urls.isEmpty() ? null : urls.iterator().next();
|
||||
}
|
||||
|
||||
public List<URL> toUrls() {
|
||||
|
|
@ -337,7 +337,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
if (unexported) {
|
||||
return;
|
||||
}
|
||||
if (exporters != null && exporters.size() > 0) {
|
||||
if (exporters != null && !exporters.isEmpty()) {
|
||||
for (Exporter<?> exporter : exporters) {
|
||||
try {
|
||||
exporter.unexport();
|
||||
|
|
@ -376,7 +376,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
appendParameters(map, provider, Constants.DEFAULT_KEY);
|
||||
appendParameters(map, protocolConfig);
|
||||
appendParameters(map, this);
|
||||
if (methods != null && methods.size() > 0) {
|
||||
if (methods != null && !methods.isEmpty()) {
|
||||
for (MethodConfig method : methods) {
|
||||
appendParameters(map, method, method.getName());
|
||||
String retryKey = method.getName() + ".retry";
|
||||
|
|
@ -387,7 +387,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
}
|
||||
}
|
||||
List<ArgumentConfig> arguments = method.getArguments();
|
||||
if (arguments != null && arguments.size() > 0) {
|
||||
if (arguments != null && !arguments.isEmpty()) {
|
||||
for (ArgumentConfig argument : arguments) {
|
||||
// convert argument type
|
||||
if (argument.getType() != null && argument.getType().length() > 0) {
|
||||
|
|
@ -489,7 +489,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Export dubbo service " + interfaceClass.getName() + " to url " + url);
|
||||
}
|
||||
if (registryURLs != null && registryURLs.size() > 0) {
|
||||
if (registryURLs != null && !registryURLs.isEmpty()) {
|
||||
for (URL registryURL : registryURLs) {
|
||||
url = url.addParameterIfAbsent("dynamic", registryURL.getParameter("dynamic"));
|
||||
URL monitorUrl = loadMonitor(registryURL);
|
||||
|
|
@ -568,7 +568,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
logger.warn(e.getMessage(), e);
|
||||
}
|
||||
if (isInvalidLocalHost(hostToBind)) {
|
||||
if (registryURLs != null && registryURLs.size() > 0) {
|
||||
if (registryURLs != null && !registryURLs.isEmpty()) {
|
||||
for (URL registryURL : registryURLs) {
|
||||
try {
|
||||
Socket socket = new Socket();
|
||||
|
|
@ -693,12 +693,12 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
}
|
||||
|
||||
private void checkProtocol() {
|
||||
if ((protocols == null || protocols.size() == 0)
|
||||
if ((protocols == null || protocols.isEmpty())
|
||||
&& provider != null) {
|
||||
setProtocols(provider.getProtocols());
|
||||
}
|
||||
// backward compatibility
|
||||
if (protocols == null || protocols.size() == 0) {
|
||||
if (protocols == null || protocols.isEmpty()) {
|
||||
setProtocol(new ProtocolConfig());
|
||||
}
|
||||
for (ProtocolConfig protocolConfig : protocols) {
|
||||
|
|
|
|||
|
|
@ -129,9 +129,9 @@ public class ReferenceBean<T> extends ReferenceConfig<T> implements FactoryBean,
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((getRegistries() == null || getRegistries().size() == 0)
|
||||
&& (getConsumer() == null || getConsumer().getRegistries() == null || getConsumer().getRegistries().size() == 0)
|
||||
&& (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().size() == 0)) {
|
||||
if ((getRegistries() == null || getRegistries().isEmpty())
|
||||
&& (getConsumer() == null || getConsumer().getRegistries() == null || getConsumer().getRegistries().isEmpty())
|
||||
&& (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().isEmpty())) {
|
||||
Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false);
|
||||
if (registryConfigMap != null && registryConfigMap.size() > 0) {
|
||||
List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>();
|
||||
|
|
@ -140,7 +140,7 @@ public class ReferenceBean<T> extends ReferenceConfig<T> implements FactoryBean,
|
|||
registryConfigs.add(config);
|
||||
}
|
||||
}
|
||||
if (registryConfigs != null && registryConfigs.size() > 0) {
|
||||
if (registryConfigs != null && !registryConfigs.isEmpty()) {
|
||||
super.setRegistries(registryConfigs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
providerConfigs.add(config);
|
||||
}
|
||||
}
|
||||
if (providerConfigs.size() > 0) {
|
||||
if (!providerConfigs.isEmpty()) {
|
||||
setProviders(providerConfigs);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -200,9 +200,9 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((getRegistries() == null || getRegistries().size() == 0)
|
||||
&& (getProvider() == null || getProvider().getRegistries() == null || getProvider().getRegistries().size() == 0)
|
||||
&& (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().size() == 0)) {
|
||||
if ((getRegistries() == null || getRegistries().isEmpty())
|
||||
&& (getProvider() == null || getProvider().getRegistries() == null || getProvider().getRegistries().isEmpty())
|
||||
&& (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().isEmpty())) {
|
||||
Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false);
|
||||
if (registryConfigMap != null && registryConfigMap.size() > 0) {
|
||||
List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>();
|
||||
|
|
@ -211,7 +211,7 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
registryConfigs.add(config);
|
||||
}
|
||||
}
|
||||
if (registryConfigs != null && registryConfigs.size() > 0) {
|
||||
if (registryConfigs != null && !registryConfigs.isEmpty()) {
|
||||
super.setRegistries(registryConfigs);
|
||||
}
|
||||
}
|
||||
|
|
@ -235,8 +235,8 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((getProtocols() == null || getProtocols().size() == 0)
|
||||
&& (getProvider() == null || getProvider().getProtocols() == null || getProvider().getProtocols().size() == 0)) {
|
||||
if ((getProtocols() == null || getProtocols().isEmpty())
|
||||
&& (getProvider() == null || getProvider().getProtocols() == null || getProvider().getProtocols().isEmpty())) {
|
||||
Map<String, ProtocolConfig> protocolConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class, false, false);
|
||||
if (protocolConfigMap != null && protocolConfigMap.size() > 0) {
|
||||
List<ProtocolConfig> protocolConfigs = new ArrayList<ProtocolConfig>();
|
||||
|
|
@ -245,7 +245,7 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
protocolConfigs.add(config);
|
||||
}
|
||||
}
|
||||
if (protocolConfigs != null && protocolConfigs.size() > 0) {
|
||||
if (protocolConfigs != null && !protocolConfigs.isEmpty()) {
|
||||
super.setProtocols(protocolConfigs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ public class JValidator implements Validator {
|
|||
validate(violations, arg, classgroups);
|
||||
}
|
||||
|
||||
if (violations.size() > 0) {
|
||||
if (!violations.isEmpty()) {
|
||||
logger.error("Failed to validate service: " + clazz.getName() + ", method: " + methodName + ", cause: " + violations);
|
||||
throw new ConstraintViolationException("Failed to validate service: " + clazz.getName() + ", method: " + methodName + ", cause: " + violations, violations);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
* @return
|
||||
*/
|
||||
public static List<Configurator> toConfigurators(List<URL> urls) {
|
||||
if (urls == null || urls.size() == 0) {
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
|
@ -199,11 +199,11 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
}
|
||||
}
|
||||
// configurators
|
||||
if (configuratorUrls != null && configuratorUrls.size() > 0) {
|
||||
if (configuratorUrls != null && !configuratorUrls.isEmpty()) {
|
||||
this.configurators = toConfigurators(configuratorUrls);
|
||||
}
|
||||
// routers
|
||||
if (routerUrls != null && routerUrls.size() > 0) {
|
||||
if (routerUrls != null && !routerUrls.isEmpty()) {
|
||||
List<Router> routers = toRouters(routerUrls);
|
||||
if (routers != null) { // null - do nothing
|
||||
setRouters(routers);
|
||||
|
|
@ -212,7 +212,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
List<Configurator> localConfigurators = this.configurators; // local reference
|
||||
// merge override parameters
|
||||
this.overrideDirectoryUrl = directoryUrl;
|
||||
if (localConfigurators != null && localConfigurators.size() > 0) {
|
||||
if (localConfigurators != null && !localConfigurators.isEmpty()) {
|
||||
for (Configurator configurator : localConfigurators) {
|
||||
this.overrideDirectoryUrl = configurator.configure(overrideDirectoryUrl);
|
||||
}
|
||||
|
|
@ -239,13 +239,13 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
} else {
|
||||
this.forbidden = false; // Allow to access
|
||||
Map<String, Invoker<T>> oldUrlInvokerMap = this.urlInvokerMap; // local reference
|
||||
if (invokerUrls.size() == 0 && this.cachedInvokerUrls != null) {
|
||||
if (invokerUrls.isEmpty() && this.cachedInvokerUrls != null) {
|
||||
invokerUrls.addAll(this.cachedInvokerUrls);
|
||||
} else {
|
||||
this.cachedInvokerUrls = new HashSet<URL>();
|
||||
this.cachedInvokerUrls.addAll(invokerUrls);//Cached invoker urls, convenient for comparison
|
||||
}
|
||||
if (invokerUrls.size() == 0) {
|
||||
if (invokerUrls.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, Invoker<T>> newUrlInvokerMap = toInvokers(invokerUrls);// Translate url list to Invoker map
|
||||
|
|
@ -303,10 +303,10 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
*/
|
||||
private List<Router> toRouters(List<URL> urls) {
|
||||
List<Router> routers = new ArrayList<Router>();
|
||||
if (urls == null || urls.size() < 1) {
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
return routers;
|
||||
}
|
||||
if (urls != null && urls.size() > 0) {
|
||||
if (urls != null && !urls.isEmpty()) {
|
||||
for (URL url : urls) {
|
||||
if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
|
||||
continue;
|
||||
|
|
@ -335,7 +335,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
*/
|
||||
private Map<String, Invoker<T>> toInvokers(List<URL> urls) {
|
||||
Map<String, Invoker<T>> newUrlInvokerMap = new HashMap<String, Invoker<T>>();
|
||||
if (urls == null || urls.size() == 0) {
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
return newUrlInvokerMap;
|
||||
}
|
||||
Set<String> keys = new HashSet<String>();
|
||||
|
|
@ -408,7 +408,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap); // Merge the consumer side parameters
|
||||
|
||||
List<Configurator> localConfigurators = this.configurators; // local reference
|
||||
if (localConfigurators != null && localConfigurators.size() > 0) {
|
||||
if (localConfigurators != null && !localConfigurators.isEmpty()) {
|
||||
for (Configurator configurator : localConfigurators) {
|
||||
providerUrl = configurator.configure(providerUrl);
|
||||
}
|
||||
|
|
@ -488,7 +488,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
if (serviceMethods != null && serviceMethods.length > 0) {
|
||||
for (String method : serviceMethods) {
|
||||
List<Invoker<T>> methodInvokers = newMethodInvokerMap.get(method);
|
||||
if (methodInvokers == null || methodInvokers.size() == 0) {
|
||||
if (methodInvokers == null || methodInvokers.isEmpty()) {
|
||||
methodInvokers = newInvokersList;
|
||||
}
|
||||
newMethodInvokerMap.put(method, route(methodInvokers, method));
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class RegistryStatusChecker implements StatusChecker {
|
|||
|
||||
public Status check() {
|
||||
Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
|
||||
if (regsitries == null || regsitries.size() == 0) {
|
||||
if (regsitries == null || regsitries.isEmpty()) {
|
||||
return new Status(Status.Level.UNKNOWN);
|
||||
}
|
||||
Status.Level level = Status.Level.OK;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public abstract class AbstractRegistry implements Registry {
|
|||
}
|
||||
|
||||
protected static List<URL> filterEmpty(URL url, List<URL> urls) {
|
||||
if (urls == null || urls.size() == 0) {
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
List<URL> result = new ArrayList<URL>(1);
|
||||
result.add(url.setProtocol(Constants.EMPTY_PROTOCOL));
|
||||
return result;
|
||||
|
|
@ -253,7 +253,7 @@ public abstract class AbstractRegistry implements Registry {
|
|||
};
|
||||
subscribe(url, listener); // Subscribe logic guarantees the first notify to return
|
||||
List<URL> urls = reference.get();
|
||||
if (urls != null && urls.size() > 0) {
|
||||
if (urls != null && !urls.isEmpty()) {
|
||||
for (URL u : urls) {
|
||||
if (!Constants.EMPTY_PROTOCOL.equals(u.getProtocol())) {
|
||||
result.add(u);
|
||||
|
|
@ -374,7 +374,7 @@ public abstract class AbstractRegistry implements Registry {
|
|||
if (listener == null) {
|
||||
throw new IllegalArgumentException("notify listener == null");
|
||||
}
|
||||
if ((urls == null || urls.size() == 0)
|
||||
if ((urls == null || urls.isEmpty())
|
||||
&& !Constants.ANY_VALUE.equals(url.getServiceInterface())) {
|
||||
logger.warn("Ignore empty notify urls for subscribe url " + url);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ public abstract class FailbackRegistry extends AbstractRegistry {
|
|||
Throwable t = e;
|
||||
|
||||
List<URL> urls = getCacheUrls(url);
|
||||
if (urls != null && urls.size() > 0) {
|
||||
if (urls != null && !urls.isEmpty()) {
|
||||
notify(url, listener, urls);
|
||||
logger.error("Failed to subscribe " + url + ", Using cached list: " + urls + " from cache file: " + getUrl().getParameter(Constants.FILE_KEY, System.getProperty("user.home") + "/dubbo-registry-" + url.getHost() + ".cache") + ", cause: " + t.getMessage(), t);
|
||||
} else {
|
||||
|
|
@ -339,7 +339,7 @@ public abstract class FailbackRegistry extends AbstractRegistry {
|
|||
}
|
||||
if (!failedUnregistered.isEmpty()) {
|
||||
Set<URL> failed = new HashSet<URL>(failedUnregistered);
|
||||
if (failed.size() > 0) {
|
||||
if (!failed.isEmpty()) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Retry unregister " + failed);
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ public abstract class FailbackRegistry extends AbstractRegistry {
|
|||
if (!failedUnsubscribed.isEmpty()) {
|
||||
Map<URL, Set<NotifyListener>> failed = new HashMap<URL, Set<NotifyListener>>(failedUnsubscribed);
|
||||
for (Map.Entry<URL, Set<NotifyListener>> entry : new HashMap<URL, Set<NotifyListener>>(failed).entrySet()) {
|
||||
if (entry.getValue() == null || entry.getValue().size() == 0) {
|
||||
if (entry.getValue() == null || entry.getValue().isEmpty()) {
|
||||
failed.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
} else if (msg.startsWith(Constants.SUBSCRIBE)) {
|
||||
URL url = URL.valueOf(msg.substring(Constants.SUBSCRIBE.length()).trim());
|
||||
Set<URL> urls = getRegistered();
|
||||
if (urls != null && urls.size() > 0) {
|
||||
if (urls != null && !urls.isEmpty()) {
|
||||
for (URL u : urls) {
|
||||
if (UrlUtils.isMatch(url, u)) {
|
||||
String host = remoteAddress != null && remoteAddress.getAddress() != null
|
||||
|
|
@ -359,7 +359,7 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
|
||||
private List<URL> toList(Set<URL> urls) {
|
||||
List<URL> list = new ArrayList<URL>();
|
||||
if (urls != null && urls.size() > 0) {
|
||||
if (urls != null && !urls.isEmpty()) {
|
||||
for (URL url : urls) {
|
||||
list.add(url);
|
||||
}
|
||||
|
|
@ -395,13 +395,13 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
urls.addAll(values);
|
||||
}
|
||||
}
|
||||
if (urls == null || urls.size() == 0) {
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
List<URL> cacheUrls = getCacheUrls(url);
|
||||
if (cacheUrls != null && cacheUrls.size() > 0) {
|
||||
if (cacheUrls != null && !cacheUrls.isEmpty()) {
|
||||
urls.addAll(cacheUrls);
|
||||
}
|
||||
}
|
||||
if (urls == null || urls.size() == 0) {
|
||||
if (urls == null || urls.isEmpty()) {
|
||||
for (URL u : getRegistered()) {
|
||||
if (UrlUtils.isMatch(url, u)) {
|
||||
urls.add(u);
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ public class RedisRegistry extends FailbackRegistry {
|
|||
// The monitoring center is responsible for deleting outdated dirty data
|
||||
private void clean(Jedis jedis) {
|
||||
Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
|
||||
if (keys != null && keys.size() > 0) {
|
||||
if (keys != null && !keys.isEmpty()) {
|
||||
for (String key : keys) {
|
||||
Map<String, String> values = jedis.hgetAll(key);
|
||||
if (values != null && values.size() > 0) {
|
||||
|
|
@ -352,7 +352,7 @@ public class RedisRegistry extends FailbackRegistry {
|
|||
if (service.endsWith(Constants.ANY_VALUE)) {
|
||||
admin = true;
|
||||
Set<String> keys = jedis.keys(service);
|
||||
if (keys != null && keys.size() > 0) {
|
||||
if (keys != null && !keys.isEmpty()) {
|
||||
Map<String, Set<String>> serviceKeys = new HashMap<String, Set<String>>();
|
||||
for (String key : keys) {
|
||||
String serviceKey = toServicePath(key);
|
||||
|
|
@ -399,8 +399,8 @@ public class RedisRegistry extends FailbackRegistry {
|
|||
}
|
||||
|
||||
private void doNotify(Jedis jedis, Collection<String> keys, URL url, Collection<NotifyListener> listeners) {
|
||||
if (keys == null || keys.size() == 0
|
||||
|| listeners == null || listeners.size() == 0) {
|
||||
if (keys == null || keys.isEmpty()
|
||||
|| listeners == null || listeners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
|
|
@ -442,7 +442,7 @@ public class RedisRegistry extends FailbackRegistry {
|
|||
logger.info("redis notify: " + key + " = " + urls);
|
||||
}
|
||||
}
|
||||
if (result == null || result.size() == 0) {
|
||||
if (result == null || result.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (NotifyListener listener : listeners) {
|
||||
|
|
@ -584,7 +584,7 @@ public class RedisRegistry extends FailbackRegistry {
|
|||
if (!first) {
|
||||
first = false;
|
||||
Set<String> keys = jedis.keys(service);
|
||||
if (keys != null && keys.size() > 0) {
|
||||
if (keys != null && !keys.isEmpty()) {
|
||||
for (String s : keys) {
|
||||
doNotify(jedis, s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public class ZookeeperRegistry extends FailbackRegistry {
|
|||
}
|
||||
zkClient.create(root, false);
|
||||
List<String> services = zkClient.addChildListener(root, zkListener);
|
||||
if (services != null && services.size() > 0) {
|
||||
if (services != null && !services.isEmpty()) {
|
||||
for (String service : services) {
|
||||
service = URL.decode(service);
|
||||
anyServices.add(service);
|
||||
|
|
@ -258,7 +258,7 @@ public class ZookeeperRegistry extends FailbackRegistry {
|
|||
|
||||
private List<URL> toUrlsWithoutEmpty(URL consumer, List<String> providers) {
|
||||
List<URL> urls = new ArrayList<URL>();
|
||||
if (providers != null && providers.size() > 0) {
|
||||
if (providers != null && !providers.isEmpty()) {
|
||||
for (String provider : providers) {
|
||||
provider = URL.decode(provider);
|
||||
if (provider.contains("://")) {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class HeaderExchangeServer implements ExchangeServer {
|
|||
public Collection<ExchangeChannel> getExchangeChannels() {
|
||||
Collection<ExchangeChannel> exchangeChannels = new ArrayList<ExchangeChannel>();
|
||||
Collection<Channel> channels = server.getChannels();
|
||||
if (channels != null && channels.size() > 0) {
|
||||
if (channels != null && !channels.isEmpty()) {
|
||||
for (Channel channel : channels) {
|
||||
exchangeChannels.add(HeaderExchangeChannel.getOrAddChannel(channel));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public class TelnetCodec extends TransportCodec {
|
|||
boolean down = endsWith(message, DOWN);
|
||||
if (up || down) {
|
||||
LinkedList<String> history = (LinkedList<String>) channel.getAttribute(HISTORY_LIST_KEY);
|
||||
if (history == null || history.size() == 0) {
|
||||
if (history == null || history.isEmpty()) {
|
||||
return DecodeResult.NEED_MORE_INPUT;
|
||||
}
|
||||
Integer index = (Integer) channel.getAttribute(HISTORY_INDEX_KEY);
|
||||
|
|
@ -256,7 +256,7 @@ public class TelnetCodec extends TransportCodec {
|
|||
LinkedList<String> history = (LinkedList<String>) channel.getAttribute(HISTORY_LIST_KEY);
|
||||
Integer index = (Integer) channel.getAttribute(HISTORY_INDEX_KEY);
|
||||
channel.removeAttribute(HISTORY_INDEX_KEY);
|
||||
if (history != null && history.size() > 0 && index != null && index >= 0 && index < history.size()) {
|
||||
if (history != null && !history.isEmpty() && index != null && index >= 0 && index < history.size()) {
|
||||
String value = history.get(index);
|
||||
if (value != null) {
|
||||
byte[] b1 = value.getBytes();
|
||||
|
|
@ -276,7 +276,7 @@ public class TelnetCodec extends TransportCodec {
|
|||
history = new LinkedList<String>();
|
||||
channel.setAttribute(HISTORY_LIST_KEY, history);
|
||||
}
|
||||
if (history.size() == 0) {
|
||||
if (history.isEmpty()) {
|
||||
history.addLast(result);
|
||||
} else if (!result.equals(history.getLast())) {
|
||||
history.remove(result);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class HelpTelnetHandler implements TelnetHandler {
|
|||
} else {
|
||||
List<List<String>> table = new ArrayList<List<String>>();
|
||||
List<TelnetHandler> handlers = extensionLoader.getActivateExtension(channel.getUrl(), "telnet");
|
||||
if (handlers != null && handlers.size() > 0) {
|
||||
if (handlers != null && !handlers.isEmpty()) {
|
||||
for (TelnetHandler handler : handlers) {
|
||||
Help help = handler.getClass().getAnnotation(Help.class);
|
||||
List<String> row = new ArrayList<String>();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class StatusTelnetHandler implements TelnetHandler {
|
|||
String[] header = new String[]{"resource", "status", "message"};
|
||||
List<List<String>> table = new ArrayList<List<String>>();
|
||||
Map<String, Status> statuses = new HashMap<String, Status>();
|
||||
if (checkers != null && checkers.size() > 0) {
|
||||
if (checkers != null && !checkers.isEmpty()) {
|
||||
for (StatusChecker checker : checkers) {
|
||||
String name = extensionLoader.getExtensionName(checker);
|
||||
Status stat;
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ public abstract class AbstractServer extends AbstractEndpoint implements Server
|
|||
@Override
|
||||
public void disconnected(Channel ch) throws RemotingException {
|
||||
Collection<Channel> channels = getChannels();
|
||||
if (channels.size() == 0) {
|
||||
if (channels.isEmpty()) {
|
||||
logger.warn("All clients has discontected from " + ch.getLocalAddress() + ". You can graceful shutdown now.");
|
||||
}
|
||||
super.disconnected(ch);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
|
|||
}
|
||||
|
||||
public ChannelHandlerDispatcher(Collection<ChannelHandler> handlers) {
|
||||
if (handlers != null && handlers.size() > 0) {
|
||||
if (handlers != null && !handlers.isEmpty()) {
|
||||
this.channelHandlers.addAll(handlers);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class NettyServer extends AbstractServer implements Server {
|
|||
}
|
||||
try {
|
||||
Collection<com.alibaba.dubbo.remoting.Channel> channels = getChannels();
|
||||
if (channels != null && channels.size() > 0) {
|
||||
if (channels != null && !channels.isEmpty()) {
|
||||
for (com.alibaba.dubbo.remoting.Channel channel : channels) {
|
||||
try {
|
||||
channel.close();
|
||||
|
|
|
|||
|
|
@ -557,7 +557,7 @@ public class RpcContext {
|
|||
|
||||
public RpcContext setInvokers(List<Invoker<?>> invokers) {
|
||||
this.invokers = invokers;
|
||||
if (invokers != null && invokers.size() > 0) {
|
||||
if (invokers != null && !invokers.isEmpty()) {
|
||||
List<URL> urls = new ArrayList<URL>(invokers.size());
|
||||
for (Invoker<?> invoker : invokers) {
|
||||
urls.add(invoker.getUrl());
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class ListenerExporterWrapper<T> implements Exporter<T> {
|
|||
}
|
||||
this.exporter = exporter;
|
||||
this.listeners = listeners;
|
||||
if (listeners != null && listeners.size() > 0) {
|
||||
if (listeners != null && !listeners.isEmpty()) {
|
||||
RuntimeException exception = null;
|
||||
for (ExporterListener listener : listeners) {
|
||||
if (listener != null) {
|
||||
|
|
@ -67,7 +67,7 @@ public class ListenerExporterWrapper<T> implements Exporter<T> {
|
|||
try {
|
||||
exporter.unexport();
|
||||
} finally {
|
||||
if (listeners != null && listeners.size() > 0) {
|
||||
if (listeners != null && !listeners.isEmpty()) {
|
||||
RuntimeException exception = null;
|
||||
for (ExporterListener listener : listeners) {
|
||||
if (listener != null) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class ListenerInvokerWrapper<T> implements Invoker<T> {
|
|||
}
|
||||
this.invoker = invoker;
|
||||
this.listeners = listeners;
|
||||
if (listeners != null && listeners.size() > 0) {
|
||||
if (listeners != null && !listeners.isEmpty()) {
|
||||
for (InvokerListener listener : listeners) {
|
||||
if (listener != null) {
|
||||
try {
|
||||
|
|
@ -82,7 +82,7 @@ public class ListenerInvokerWrapper<T> implements Invoker<T> {
|
|||
try {
|
||||
invoker.destroy();
|
||||
} finally {
|
||||
if (listeners != null && listeners.size() > 0) {
|
||||
if (listeners != null && !listeners.isEmpty()) {
|
||||
for (InvokerListener listener : listeners) {
|
||||
if (listener != null) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ProtocolFilterWrapper implements Protocol {
|
|||
private static <T> Invoker<T> buildInvokerChain(final Invoker<T> invoker, String key, String group) {
|
||||
Invoker<T> last = invoker;
|
||||
List<Filter> filters = ExtensionLoader.getExtensionLoader(Filter.class).getActivateExtension(invoker.getUrl(), key, group);
|
||||
if (filters.size() > 0) {
|
||||
if (!filters.isEmpty()) {
|
||||
for (int i = filters.size() - 1; i >= 0; i--) {
|
||||
final Filter filter = filters.get(i);
|
||||
final Invoker<T> next = last;
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@ public class TraceFilter implements Filter {
|
|||
if (tracers.size() > 0) {
|
||||
String key = invoker.getInterface().getName() + "." + invocation.getMethodName();
|
||||
Set<Channel> channels = tracers.get(key);
|
||||
if (channels == null || channels.size() == 0) {
|
||||
if (channels == null || channels.isEmpty()) {
|
||||
key = invoker.getInterface().getName();
|
||||
channels = tracers.get(key);
|
||||
}
|
||||
if (channels != null && channels.size() > 0) {
|
||||
if (channels != null && !channels.isEmpty()) {
|
||||
for (Channel channel : new ArrayList<Channel>(channels)) {
|
||||
if (channel.isConnected()) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class ServerStatusChecker implements StatusChecker {
|
|||
|
||||
public Status check() {
|
||||
Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
|
||||
if (servers == null || servers.size() == 0) {
|
||||
if (servers == null || servers.isEmpty()) {
|
||||
return new Status(Status.Level.UNKNOWN);
|
||||
}
|
||||
Status.Level level = Status.Level.OK;
|
||||
|
|
|
|||
Loading…
Reference in New Issue