Skip to content

Commit 9eca39b

Browse files
committed
fix #7315 redundant box for boolean and refactor method filterInvoker
1 parent fcc6298 commit 9eca39b

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

  • dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation
160160
* @return
161161
*/
162162
private <T> List<Invoker<T>> filterUsingStaticTag(List<Invoker<T>> invokers, URL url, Invocation invocation) {
163-
List<Invoker<T>> result = invokers;
163+
List<Invoker<T>> result;
164164
// Dynamic param
165165
String tag = StringUtils.isEmpty(invocation.getAttachment(TAG_KEY)) ? url.getParameter(TAG_KEY) :
166166
invocation.getAttachment(TAG_KEY);
@@ -188,19 +188,11 @@ public boolean isForce() {
188188
}
189189

190190
private boolean isForceUseTag(Invocation invocation) {
191-
return Boolean.valueOf(invocation.getAttachment(FORCE_USE_TAG, url.getParameter(FORCE_USE_TAG, "false")));
191+
return Boolean.parseBoolean(invocation.getAttachment(FORCE_USE_TAG, url.getParameter(FORCE_USE_TAG, "false")));
192192
}
193193

194194
private <T> List<Invoker<T>> filterInvoker(List<Invoker<T>> invokers, Predicate<Invoker<T>> predicate) {
195-
boolean filter = false;
196-
for (int i = 0; i < invokers.size(); ++i) {
197-
Invoker<T> invoker = invokers.get(i);
198-
if (!predicate.test(invoker)) {
199-
filter = true;
200-
break;
201-
}
202-
}
203-
if (!filter) {
195+
if (invokers.stream().allMatch(predicate)) {
204196
return invokers;
205197
}
206198

0 commit comments

Comments
 (0)