From 18dee4e44df7a02cacb3070fda72e22d7078f910 Mon Sep 17 00:00:00 2001 From: Lei Jiang Date: Fri, 21 Sep 2018 08:57:27 +0800 Subject: [PATCH] code format (#2528) --- .../cluster/directory/AbstractDirectory.java | 3 +- .../cluster/directory/StaticDirectory.java | 3 +- .../loadbalance/AbstractLoadBalance.java | 6 +- .../loadbalance/LeastActiveLoadBalance.java | 3 +- .../cluster/router/MockInvokersSelector.java | 4 +- .../router/condition/ConditionRouter.java | 9 ++- .../support/AbstractClusterInvoker.java | 6 +- .../support/jvalidation/JValidator.java | 23 +++---- .../org/apache/dubbo/metrics/MetricName.java | 66 ++++++++++++------- .../dubbo/monitor/dubbo/Statistics.java | 51 +++++++++----- .../integration/RegistryDirectory.java | 9 ++- .../registry/support/AbstractRegistry.java | 4 +- .../dubbo/registry/dubbo/DubboRegistry.java | 3 +- .../dubbo/registry/redis/RedisRegistry.java | 24 ++++--- .../dubbo/remoting/exchange/Request.java | 4 +- .../support/header/HeaderExchangeChannel.java | 20 ++++-- .../support/header/HeaderExchangeServer.java | 3 +- .../transport/grizzly/GrizzlyClient.java | 3 +- .../remoting/transport/mina/MinaClient.java | 3 +- .../transport/netty4/NettyChannel.java | 20 ++++-- .../java/CompactedObjectInputStream.java | 3 +- 21 files changed, 180 insertions(+), 90 deletions(-) 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 52f58112774..0cea0b859fc 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 AbstractDirectory(URL url, List routers) { } 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 47a0d12bc7d..cc6bab3c9e1 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 StaticDirectory(URL url, List> invokers) { 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 ff94b3cf578..7a8d0aaaba7 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 @@ static int calculateWarmupWeight(int uptime, int warmup, int weight) { @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 956ff7709fb..d0ea49ca8c8 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 @@ protected Invoker doSelect(List> invokers, URL url, Invocation 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 0ca2a4997d6..35ce7e5331c 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 List> route(final List> invokers, 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 af367570288..503ede9430b 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 @@ else if ("&".equals(separator)) { } // 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 51fe092a059..59b16ed500d 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 AbstractClusterInvoker(Directory directory) { } 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 void destroy() { * @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 328c54c7490..a7c8afe3f29 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 @@ private static String toUpperMethoName(String methodName) { // 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 93ae922696a..ca7edb9292a 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 static MetricName join(MetricName... parts) { 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 static MetricName join(MetricName... parts) { * @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 @@ private static String buildName(String... names) { 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 int hashCode() { @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 @@ private int compareTags(Map left, Map right) { 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 cf9138ec7fc..bba7ac2bb18 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 int hashCode() { @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 6b366b2921b..3a79cac5e2b 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 @@ private List toRouters(List urls) { } 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 406b8a81a3b..61360f07749 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 @@ protected void recover() throws Exception { } 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 60b4636d5b2..45c94a73e48 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 @@ protected final void connect() { @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 b2be1647878..d37276345df 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 RedisRegistry(URL url) { 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 e1f45fd56a5..abd058294b3 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 @@ private static long newId() { } 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 73503cd4c2d..4aef993a2e2 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 @@ public int hashCode() { @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 0b4aba067b3..8eceb182e4b 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 @@ private void sendChannelReadOnlyEvent() { 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 a929af3b441..30f47b8d728 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 @@ protected void doClose() throws Throwable { @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 b2e4a6caa74..552becd3258 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 @@ protected void doClose() throws Throwable { @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 39de3d9c61c..db69a29f24c 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 @@ public int hashCode() { @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 2587e597cf6..a6bda0aca99 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 CompactedObjectInputStream(InputStream in, ClassLoader cl) throws IOExcep @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();