diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java index 52f5811277..0cea0b859f 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java @@ -59,8 +59,9 @@ public abstract class AbstractDirectory implements Directory { } public AbstractDirectory(URL url, URL consumerUrl, List routers) { - if (url == null) + if (url == null) { throw new IllegalArgumentException("url == null"); + } this.url = url; this.consumerUrl = consumerUrl; setRouters(routers); diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java index 47a0d12bc7..cc6bab3c9e 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java @@ -46,8 +46,9 @@ public class StaticDirectory extends AbstractDirectory { public StaticDirectory(URL url, List> invokers, List routers) { super(url == null && invokers != null && !invokers.isEmpty() ? invokers.get(0).getUrl() : url, routers); - if (invokers == null || invokers.isEmpty()) + if (invokers == null || invokers.isEmpty()) { throw new IllegalArgumentException("invokers == null"); + } this.invokers = invokers; } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java index ff94b3cf57..7a8d0aaaba 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java @@ -37,10 +37,12 @@ public abstract class AbstractLoadBalance implements LoadBalance { @Override public Invoker select(List> invokers, URL url, Invocation invocation) { - if (invokers == null || invokers.isEmpty()) + if (invokers == null || invokers.isEmpty()) { return null; - if (invokers.size() == 1) + } + if (invokers.size() == 1) { return invokers.get(0); + } return doSelect(invokers, url, invocation); } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java index 956ff7709f..d0ea49ca8c 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java @@ -75,8 +75,9 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance { for (int i = 0; i < leastCount; i++) { int leastIndex = leastIndexes[i]; offsetWeight -= getWeight(invokers.get(leastIndex), invocation); - if (offsetWeight <= 0) + if (offsetWeight <= 0) { return invokers.get(leastIndex); + } } } // If all invokers have the same weight value or totalWeight=0, return evenly. diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/MockInvokersSelector.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/MockInvokersSelector.java index 0ca2a4997d..35ce7e5331 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/MockInvokersSelector.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/MockInvokersSelector.java @@ -40,9 +40,9 @@ public class MockInvokersSelector implements Router { return getNormalInvokers(invokers); } else { String value = invocation.getAttachments().get(Constants.INVOCATION_NEED_MOCK); - if (value == null) + if (value == null) { return getNormalInvokers(invokers); - else if (Boolean.TRUE.toString().equalsIgnoreCase(value)) { + } else if (Boolean.TRUE.toString().equalsIgnoreCase(value)) { return getMockedInvokers(invokers); } } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionRouter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionRouter.java index af36757028..503ede9430 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionRouter.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionRouter.java @@ -105,33 +105,36 @@ public class ConditionRouter implements Router, Comparable { } // The Value in the KV part. else if ("=".equals(separator)) { - if (pair == null) + if (pair == null) { throw new ParseException("Illegal route rule \"" + rule + "\", The error char '" + separator + "' at index " + matcher.start() + " before \"" + content + "\".", matcher.start()); + } values = pair.matches; values.add(content); } // The Value in the KV part. else if ("!=".equals(separator)) { - if (pair == null) + if (pair == null) { throw new ParseException("Illegal route rule \"" + rule + "\", The error char '" + separator + "' at index " + matcher.start() + " before \"" + content + "\".", matcher.start()); + } values = pair.mismatches; values.add(content); } // 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.isEmpty()) + if (values == null || values.isEmpty()) { throw new ParseException("Illegal route rule \"" + rule + "\", The error char '" + separator + "' at index " + matcher.start() + " before \"" + content + "\".", matcher.start()); + } values.add(content); } else { throw new ParseException("Illegal route rule \"" + rule diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java index 51fe092a05..59b16ed500 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java @@ -59,8 +59,9 @@ public abstract class AbstractClusterInvoker implements Invoker { } public AbstractClusterInvoker(Directory directory, URL url) { - if (directory == null) + if (directory == null) { throw new IllegalArgumentException("service directory == null"); + } this.directory = directory; //sticky: invoker.isAvailable() should always be checked before using when availablecheck is true. @@ -110,8 +111,9 @@ public abstract class AbstractClusterInvoker implements Invoker { * @throws RpcException */ protected Invoker select(LoadBalance loadbalance, Invocation invocation, List> invokers, List> selected) throws RpcException { - if (invokers == null || invokers.isEmpty()) + if (invokers == null || invokers.isEmpty()) { return null; + } String methodName = invocation == null ? "" : invocation.getMethodName(); boolean sticky = invokers.get(0).getUrl().getMethodParameter(methodName, Constants.CLUSTER_STICKY_KEY, Constants.DEFAULT_CLUSTER_STICKY); diff --git a/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java b/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java index 328c54c749..a7c8afe3f2 100644 --- a/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java +++ b/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java @@ -202,28 +202,29 @@ public class JValidator implements Validator { // Copy from javassist.bytecode.annotation.Annotation.createMemberValue(ConstPool, CtClass); private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException { MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type); - if (memberValue instanceof BooleanMemberValue) + if (memberValue instanceof BooleanMemberValue) { ((BooleanMemberValue) memberValue).setValue((Boolean) value); - else if (memberValue instanceof ByteMemberValue) + } else if (memberValue instanceof ByteMemberValue) { ((ByteMemberValue) memberValue).setValue((Byte) value); - else if (memberValue instanceof CharMemberValue) + } else if (memberValue instanceof CharMemberValue) { ((CharMemberValue) memberValue).setValue((Character) value); - else if (memberValue instanceof ShortMemberValue) + } else if (memberValue instanceof ShortMemberValue) { ((ShortMemberValue) memberValue).setValue((Short) value); - else if (memberValue instanceof IntegerMemberValue) + } else if (memberValue instanceof IntegerMemberValue) { ((IntegerMemberValue) memberValue).setValue((Integer) value); - else if (memberValue instanceof LongMemberValue) + } else if (memberValue instanceof LongMemberValue) { ((LongMemberValue) memberValue).setValue((Long) value); - else if (memberValue instanceof FloatMemberValue) + } else if (memberValue instanceof FloatMemberValue) { ((FloatMemberValue) memberValue).setValue((Float) value); - else if (memberValue instanceof DoubleMemberValue) + } else if (memberValue instanceof DoubleMemberValue) { ((DoubleMemberValue) memberValue).setValue((Double) value); - else if (memberValue instanceof ClassMemberValue) + } else if (memberValue instanceof ClassMemberValue) { ((ClassMemberValue) memberValue).setValue(((Class) value).getName()); - else if (memberValue instanceof StringMemberValue) + } else if (memberValue instanceof StringMemberValue) { ((StringMemberValue) memberValue).setValue((String) value); - else if (memberValue instanceof EnumMemberValue) + } else if (memberValue instanceof EnumMemberValue) { ((EnumMemberValue) memberValue).setValue(((Enum) value).name()); + } /* else if (memberValue instanceof AnnotationMemberValue) */ else if (memberValue instanceof ArrayMemberValue) { CtClass arrayType = type.getComponentType(); diff --git a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/MetricName.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/MetricName.java index 93ae922696..ca7edb9292 100644 --- a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/MetricName.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/MetricName.java @@ -204,8 +204,9 @@ public class MetricName implements Comparable { nameBuilder.append(name); } - if (!part.getTags().isEmpty()) + if (!part.getTags().isEmpty()) { tags.putAll(part.getTags()); + } } MetricLevel level = firstName == null ? null : firstName.getMetricLevel(); @@ -219,11 +220,13 @@ public class MetricName implements Comparable { * @return A newly created metric name with the specified path. **/ public static MetricName build(String... parts) { - if (parts == null || parts.length == 0) + if (parts == null || parts.length == 0) { return MetricName.EMPTY; + } - if (parts.length == 1) + if (parts.length == 1) { return new MetricName(parts[0], EMPTY_TAGS); + } return new MetricName(buildName(parts), EMPTY_TAGS); } @@ -233,8 +236,9 @@ public class MetricName implements Comparable { boolean first = true; for (String name : names) { - if (name == null || name.isEmpty()) + if (name == null || name.isEmpty()) { continue; + } if (first) { first = false; @@ -276,64 +280,78 @@ public class MetricName implements Comparable { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; + } - if (obj == null) + if (obj == null) { return false; + } - if (getClass() != obj.getClass()) + if (getClass() != obj.getClass()) { return false; + } MetricName other = (MetricName) obj; if (key == null) { - if (other.key != null) + if (other.key != null) { return false; - } else if (!key.equals(other.key)) + } + } else if (!key.equals(other.key)) { return false; + } - if (!tags.equals(other.tags)) + if (!tags.equals(other.tags)) { return false; + } return true; } @Override public int compareTo(MetricName o) { - if (o == null) + if (o == null) { return -1; + } int c = compareName(key, o.getKey()); - if (c != 0) + if (c != 0) { return c; + } return compareTags(tags, o.getTags()); } private int compareName(String left, String right) { - if (left == null && right == null) + if (left == null && right == null) { return 0; + } - if (left == null) + if (left == null) { return 1; + } - if (right == null) + if (right == null) { return -1; + } return left.compareTo(right); } private int compareTags(Map left, Map right) { - if (left == null && right == null) + if (left == null && right == null) { return 0; + } - if (left == null) + if (left == null) { return 1; + } - if (right == null) + if (right == null) { return -1; + } final Iterable keys = uniqueSortedKeys(left, right); @@ -341,19 +359,23 @@ public class MetricName implements Comparable { final String a = left.get(key); final String b = right.get(key); - if (a == null && b == null) + if (a == null && b == null) { continue; + } - if (a == null) + if (a == null) { return -1; + } - if (b == null) + if (b == null) { return 1; + } int c = a.compareTo(b); - if (c != 0) + if (c != 0) { return c; + } } return 0; diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/Statistics.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/Statistics.java index cf9138ec7f..bba7ac2bb1 100644 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/Statistics.java +++ b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/Statistics.java @@ -140,48 +140,65 @@ public class Statistics implements Serializable { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Statistics other = (Statistics) obj; if (application == null) { - if (other.application != null) + if (other.application != null) { return false; - } else if (!application.equals(other.application)) + } + } else if (!application.equals(other.application)) { return false; + } if (client == null) { - if (other.client != null) + if (other.client != null) { return false; - } else if (!client.equals(other.client)) + } + } else if (!client.equals(other.client)) { return false; + } if (group == null) { - if (other.group != null) + if (other.group != null) { return false; - } else if (!group.equals(other.group)) + } + } else if (!group.equals(other.group)) { return false; + } if (method == null) { - if (other.method != null) + if (other.method != null) { return false; - } else if (!method.equals(other.method)) + } + } else if (!method.equals(other.method)) { return false; + } if (server == null) { - if (other.server != null) + if (other.server != null) { return false; - } else if (!server.equals(other.server)) + } + } else if (!server.equals(other.server)) { return false; + } if (service == null) { - if (other.service != null) + if (other.service != null) { return false; - } else if (!service.equals(other.service)) + } + } else if (!service.equals(other.service)) { return false; + } if (version == null) { - if (other.version != null) + if (other.version != null) { return false; - } else if (!version.equals(other.version)) + } + } else if (!version.equals(other.version)) { return false; + } return true; } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java index 6b366b2921..3a79cac5e2 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java @@ -96,10 +96,12 @@ public class RegistryDirectory extends AbstractDirectory implements Notify public RegistryDirectory(Class serviceType, URL url) { super(url); - if (serviceType == null) + if (serviceType == null) { throw new IllegalArgumentException("service type is null."); - if (url.getServiceKey() == null || url.getServiceKey().length() == 0) + } + if (url.getServiceKey() == null || url.getServiceKey().length() == 0) { throw new IllegalArgumentException("registry serviceKey is null."); + } this.serviceType = serviceType; this.serviceKey = url.getServiceKey(); this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY)); @@ -318,8 +320,9 @@ public class RegistryDirectory extends AbstractDirectory implements Notify } try { Router router = routerFactory.getRouter(url); - if (!routers.contains(router)) + if (!routers.contains(router)) { routers.add(router); + } } catch (Throwable t) { logger.error("convert router url to router error, url: " + url, t); } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java index 406b8a81a3..61360f0774 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java @@ -349,7 +349,9 @@ public abstract class AbstractRegistry implements Registry { } protected void notify(List urls) { - if (urls == null || urls.isEmpty()) return; + if (urls == null || urls.isEmpty()) { + return; + } for (Map.Entry> entry : getSubscribed().entrySet()) { URL url = entry.getKey(); diff --git a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java index 60b4636d5b..45c94a73e4 100644 --- a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java +++ b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java @@ -116,8 +116,9 @@ public class DubboRegistry extends FailbackRegistry { @Override public boolean isAvailable() { - if (registryInvoker == null) + if (registryInvoker == null) { return false; + } return registryInvoker.isAvailable(); } diff --git a/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java b/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java index b2be164787..d37276345d 100644 --- a/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java +++ b/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java @@ -90,22 +90,30 @@ public class RedisRegistry extends FailbackRegistry { config.setTestOnBorrow(url.getParameter("test.on.borrow", true)); config.setTestOnReturn(url.getParameter("test.on.return", false)); config.setTestWhileIdle(url.getParameter("test.while.idle", false)); - if (url.getParameter("max.idle", 0) > 0) + if (url.getParameter("max.idle", 0) > 0) { config.setMaxIdle(url.getParameter("max.idle", 0)); - if (url.getParameter("min.idle", 0) > 0) + } + if (url.getParameter("min.idle", 0) > 0) { config.setMinIdle(url.getParameter("min.idle", 0)); - if (url.getParameter("max.active", 0) > 0) + } + if (url.getParameter("max.active", 0) > 0) { config.setMaxTotal(url.getParameter("max.active", 0)); - if (url.getParameter("max.total", 0) > 0) + } + if (url.getParameter("max.total", 0) > 0) { config.setMaxTotal(url.getParameter("max.total", 0)); - if (url.getParameter("max.wait", url.getParameter("timeout", 0)) > 0) + } + if (url.getParameter("max.wait", url.getParameter("timeout", 0)) > 0) { config.setMaxWaitMillis(url.getParameter("max.wait", url.getParameter("timeout", 0))); - if (url.getParameter("num.tests.per.eviction.run", 0) > 0) + } + if (url.getParameter("num.tests.per.eviction.run", 0) > 0) { config.setNumTestsPerEvictionRun(url.getParameter("num.tests.per.eviction.run", 0)); - if (url.getParameter("time.between.eviction.runs.millis", 0) > 0) + } + if (url.getParameter("time.between.eviction.runs.millis", 0) > 0) { config.setTimeBetweenEvictionRunsMillis(url.getParameter("time.between.eviction.runs.millis", 0)); - if (url.getParameter("min.evictable.idle.time.millis", 0) > 0) + } + if (url.getParameter("min.evictable.idle.time.millis", 0) > 0) { config.setMinEvictableIdleTimeMillis(url.getParameter("min.evictable.idle.time.millis", 0)); + } String cluster = url.getParameter("cluster", "failover"); if (!"failover".equals(cluster) && !"replicate".equals(cluster)) { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java index e1f45fd56a..abd058294b 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java @@ -57,7 +57,9 @@ public class Request { } private static String safeToString(Object data) { - if (data == null) return null; + if (data == null) { + return null; + } String dataStr; try { dataStr = data.toString(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java index 73503cd4c2..4aef993a2e 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java @@ -221,13 +221,23 @@ final class HeaderExchangeChannel implements ExchangeChannel { @Override public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } HeaderExchangeChannel other = (HeaderExchangeChannel) obj; if (channel == null) { - if (other.channel != null) return false; - } else if (!channel.equals(other.channel)) return false; + if (other.channel != null) { + return false; + } + } else if (!channel.equals(other.channel)) { + return false; + } return true; } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java index 0b4aba067b..8eceb182e4 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java @@ -139,8 +139,9 @@ public class HeaderExchangeServer implements ExchangeServer { Collection channels = getChannels(); for (Channel channel : channels) { try { - if (channel.isConnected()) + if (channel.isConnected()) { channel.send(request, getUrl().getParameter(Constants.CHANNEL_READONLYEVENT_SENT_KEY, true)); + } } catch (RemotingException e) { logger.warn("send cannot write message error.", e); } diff --git a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyClient.java b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyClient.java index a929af3b44..30f47b8d72 100644 --- a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyClient.java +++ b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyClient.java @@ -101,8 +101,9 @@ public class GrizzlyClient extends AbstractClient { @Override protected Channel getChannel() { Connection c = connection; - if (c == null || !c.isOpen()) + if (c == null || !c.isOpen()) { return null; + } return GrizzlyChannel.getOrAddChannel(c, getUrl(), this); } diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaClient.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaClient.java index b2e4a6caa7..552becd325 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaClient.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaClient.java @@ -165,8 +165,9 @@ public class MinaClient extends AbstractClient { @Override protected Channel getChannel() { IoSession s = session; - if (s == null || !s.isConnected()) + if (s == null || !s.isConnected()) { return null; + } return MinaChannel.getOrAddChannel(s, getUrl(), this); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyChannel.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyChannel.java index 39de3d9c61..db69a29f24 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyChannel.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyChannel.java @@ -178,13 +178,23 @@ final class NettyChannel extends AbstractChannel { @Override public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } NettyChannel other = (NettyChannel) obj; if (channel == null) { - if (other.channel != null) return false; - } else if (!channel.equals(other.channel)) return false; + if (other.channel != null) { + return false; + } + } else if (!channel.equals(other.channel)) { + return false; + } return true; } diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedObjectInputStream.java b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedObjectInputStream.java index 2587e597cf..a6bda0aca9 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedObjectInputStream.java +++ b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedObjectInputStream.java @@ -43,8 +43,9 @@ public class CompactedObjectInputStream extends ObjectInputStream { @Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { int type = read(); - if (type < 0) + if (type < 0) { throw new EOFException(); + } switch (type) { case 0: return super.readClassDescriptor();