[fix] some statement can be simplified (#10525)
diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java
index 74c54ce..f8c2089 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java
@@ -43,8 +43,9 @@
/**
* Select one invoker between a list using a random criteria
- * @param invokers List of possible invokers
- * @param url URL
+ *
+ * @param invokers List of possible invokers
+ * @param url URL
* @param invocation Invocation
* @param <T>
* @return The selected invoker
@@ -54,7 +55,7 @@
// Number of invokers
int length = invokers.size();
- if (!needWeightLoadBalance(invokers,invocation)){
+ if (!needWeightLoadBalance(invokers, invocation)) {
return invokers.get(ThreadLocalRandom.current().nextInt(length));
}
@@ -89,8 +90,7 @@
}
private <T> boolean needWeightLoadBalance(List<Invoker<T>> invokers, Invocation invocation) {
-
- Invoker invoker = invokers.get(0);
+ Invoker<T> invoker = invokers.get(0);
URL invokerUrl = invoker.getUrl();
if (invoker instanceof ClusterInvoker) {
invokerUrl = ((ClusterInvoker<?>) invoker).getRegistryUrl();
@@ -99,22 +99,15 @@
// Multiple registry scenario, load balance among multiple registries.
if (REGISTRY_SERVICE_REFERENCE_PATH.equals(invokerUrl.getServiceInterface())) {
String weight = invokerUrl.getParameter(WEIGHT_KEY);
- if (StringUtils.isNotEmpty(weight)) {
- return true;
- }
+ return StringUtils.isNotEmpty(weight);
} else {
String weight = invokerUrl.getMethodParameter(invocation.getMethodName(), WEIGHT_KEY);
if (StringUtils.isNotEmpty(weight)) {
return true;
- }else {
+ } else {
String timeStamp = invoker.getUrl().getParameter(TIMESTAMP_KEY);
- if (StringUtils.isNotEmpty(timeStamp)) {
- return true;
- }
+ return StringUtils.isNotEmpty(timeStamp);
}
}
- return false;
}
-
-
}