This is an automated email from the ASF dual-hosted git repository.
iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new bb3216d Improve UT grammar and remove unnecessary braces. (#2930)
bb3216d is described below
commit bb3216d8586db05606ca27edf2a16a4ac80740ad
Author: Huxing Zhang <[email protected]>
AuthorDate: Mon Dec 10 13:43:11 2018 +0800
Improve UT grammar and remove unnecessary braces. (#2930)
* Improve UT grammer, fix compiler warnings.
* Remove unnecessary braces.
---
.../cluster/support/AbstractClusterInvoker.java | 39 +++++++++++-----------
.../rpc/cluster/directory/StaticDirectoryTest.java | 8 ++---
2 files changed, 23 insertions(+), 24 deletions(-)
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 1c24aef..2d3602a 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
@@ -121,18 +121,18 @@ public abstract class AbstractClusterInvoker<T>
implements Invoker<T> {
boolean sticky = invokers.get(0).getUrl()
.getMethodParameter(methodName, Constants.CLUSTER_STICKY_KEY,
Constants.DEFAULT_CLUSTER_STICKY);
- {
- //ignore overloaded method
- if (stickyInvoker != null && !invokers.contains(stickyInvoker)) {
- stickyInvoker = null;
- }
- //ignore concurrency problem
- if (sticky && stickyInvoker != null && (selected == null ||
!selected.contains(stickyInvoker))) {
- if (availablecheck && stickyInvoker.isAvailable()) {
- return stickyInvoker;
- }
+
+ //ignore overloaded method
+ if (stickyInvoker != null && !invokers.contains(stickyInvoker)) {
+ stickyInvoker = null;
+ }
+ //ignore concurrency problem
+ if (sticky && stickyInvoker != null && (selected == null ||
!selected.contains(stickyInvoker))) {
+ if (availablecheck && stickyInvoker.isAvailable()) {
+ return stickyInvoker;
}
}
+
Invoker<T> invoker = doSelect(loadbalance, invocation, invokers,
selected);
if (sticky) {
@@ -210,19 +210,18 @@ public abstract class AbstractClusterInvoker<T>
implements Invoker<T> {
}
// Just pick an available invoker using loadbalance policy
- {
- if (selected != null) {
- for (Invoker<T> invoker : selected) {
- if ((invoker.isAvailable()) // available first
- && !reselectInvokers.contains(invoker)) {
- reselectInvokers.add(invoker);
- }
+ if (selected != null) {
+ for (Invoker<T> invoker : selected) {
+ if ((invoker.isAvailable()) // available first
+ && !reselectInvokers.contains(invoker)) {
+ reselectInvokers.add(invoker);
}
}
- if (!reselectInvokers.isEmpty()) {
- return loadbalance.select(reselectInvokers, getUrl(),
invocation);
- }
}
+ if (!reselectInvokers.isEmpty()) {
+ return loadbalance.select(reselectInvokers, getUrl(), invocation);
+ }
+
return null;
}
diff --git
a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectoryTest.java
b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectoryTest.java
index 0bf0562..ac538b7 100644
---
a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectoryTest.java
+++
b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectoryTest.java
@@ -54,12 +54,12 @@ public class StaticDirectoryTest {
invokers.add(invoker2);
invokers.add(invoker3);
List<Invoker<String>> filteredInvokers = router.route(invokers,
URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/com.foo.BarService"),
new RpcInvocation());
- StaticDirectory staticDirectory = new
StaticDirectory(filteredInvokers);
- Boolean isAvailable = staticDirectory.isAvailable();
+ StaticDirectory<String> staticDirectory = new
StaticDirectory<>(filteredInvokers);
+ boolean isAvailable = staticDirectory.isAvailable();
Assert.assertTrue(!isAvailable);
- List<Invoker> newInvokers = staticDirectory.list(new
MockDirInvocation());
+ List<Invoker<String>> newInvokers = staticDirectory.list(new
MockDirInvocation());
Assert.assertTrue(newInvokers.size() > 0);
staticDirectory.destroy();
- Assert.assertTrue(newInvokers.size() == 0);
+ Assert.assertEquals(0, newInvokers.size());
}
}