From 9e71e23216208a71d0a445aa4a2d609fe824f975 Mon Sep 17 00:00:00 2001 From: XiaoJie Li Date: Mon, 10 Dec 2018 19:04:00 +0800 Subject: [PATCH] optimize the RondRobinLoadBalance and MockClusterInvoker (#2932) delete unused logic and take the logger out. --- .../rpc/cluster/loadbalance/RoundRobinLoadBalance.java | 1 - .../cluster/support/wrapper/MockClusterInvoker.java | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java index f0bd58ef344..242a2ffc23f 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java @@ -108,7 +108,6 @@ protected Invoker doSelect(List> invokers, URL url, Invocation weightedRoundRobin = new WeightedRoundRobin(); weightedRoundRobin.setWeight(weight); map.putIfAbsent(identifyString, weightedRoundRobin); - weightedRoundRobin = map.get(identifyString); } if (weight != weightedRoundRobin.getWeight()) { //weight changed diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java index a8a984e04eb..2fd1af923c8 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java @@ -86,12 +86,12 @@ public Result invoke(Invocation invocation) throws RpcException { } catch (RpcException e) { if (e.isBiz()) { throw e; - } else { - if (logger.isWarnEnabled()) { - logger.warn("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e); - } - result = doMockInvoke(invocation, e); } + + if (logger.isWarnEnabled()) { + logger.warn("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e); + } + result = doMockInvoke(invocation, e); } } return result;