Skip to content

Commit 83c40a5

Browse files
ralf0131khanimteyaz
authored andcommitted
Improve UT grammar and remove unnecessary braces. (apache#2930)
* Improve UT grammer, fix compiler warnings. * Remove unnecessary braces.
1 parent 5e14715 commit 83c40a5

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,18 @@ protected Invoker<T> select(LoadBalance loadbalance, Invocation invocation,
121121

122122
boolean sticky = invokers.get(0).getUrl()
123123
.getMethodParameter(methodName, Constants.CLUSTER_STICKY_KEY, Constants.DEFAULT_CLUSTER_STICKY);
124-
{
125-
//ignore overloaded method
126-
if (stickyInvoker != null && !invokers.contains(stickyInvoker)) {
127-
stickyInvoker = null;
128-
}
129-
//ignore concurrency problem
130-
if (sticky && stickyInvoker != null && (selected == null || !selected.contains(stickyInvoker))) {
131-
if (availablecheck && stickyInvoker.isAvailable()) {
132-
return stickyInvoker;
133-
}
124+
125+
//ignore overloaded method
126+
if (stickyInvoker != null && !invokers.contains(stickyInvoker)) {
127+
stickyInvoker = null;
128+
}
129+
//ignore concurrency problem
130+
if (sticky && stickyInvoker != null && (selected == null || !selected.contains(stickyInvoker))) {
131+
if (availablecheck && stickyInvoker.isAvailable()) {
132+
return stickyInvoker;
134133
}
135134
}
135+
136136
Invoker<T> invoker = doSelect(loadbalance, invocation, invokers, selected);
137137

138138
if (sticky) {
@@ -210,19 +210,18 @@ private Invoker<T> reselect(LoadBalance loadbalance, Invocation invocation,
210210
}
211211

212212
// Just pick an available invoker using loadbalance policy
213-
{
214-
if (selected != null) {
215-
for (Invoker<T> invoker : selected) {
216-
if ((invoker.isAvailable()) // available first
217-
&& !reselectInvokers.contains(invoker)) {
218-
reselectInvokers.add(invoker);
219-
}
213+
if (selected != null) {
214+
for (Invoker<T> invoker : selected) {
215+
if ((invoker.isAvailable()) // available first
216+
&& !reselectInvokers.contains(invoker)) {
217+
reselectInvokers.add(invoker);
220218
}
221219
}
222-
if (!reselectInvokers.isEmpty()) {
223-
return loadbalance.select(reselectInvokers, getUrl(), invocation);
224-
}
225220
}
221+
if (!reselectInvokers.isEmpty()) {
222+
return loadbalance.select(reselectInvokers, getUrl(), invocation);
223+
}
224+
226225
return null;
227226
}
228227

dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectoryTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public void testStaticDirectory() {
5454
invokers.add(invoker2);
5555
invokers.add(invoker3);
5656
List<Invoker<String>> filteredInvokers = router.route(invokers, URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/com.foo.BarService"), new RpcInvocation());
57-
StaticDirectory staticDirectory = new StaticDirectory(filteredInvokers);
58-
Boolean isAvailable = staticDirectory.isAvailable();
57+
StaticDirectory<String> staticDirectory = new StaticDirectory<>(filteredInvokers);
58+
boolean isAvailable = staticDirectory.isAvailable();
5959
Assert.assertTrue(!isAvailable);
60-
List<Invoker> newInvokers = staticDirectory.list(new MockDirInvocation());
60+
List<Invoker<String>> newInvokers = staticDirectory.list(new MockDirInvocation());
6161
Assert.assertTrue(newInvokers.size() > 0);
6262
staticDirectory.destroy();
63-
Assert.assertTrue(newInvokers.size() == 0);
63+
Assert.assertEquals(0, newInvokers.size());
6464
}
6565
}

0 commit comments

Comments
 (0)