Skip to content

Commit

Permalink
fix apache#7315 redundant box for boolean and refactor method filterI…
Browse files Browse the repository at this point in the history
…nvoker (apache#7316)
  • Loading branch information
24kpure authored Mar 11, 2021
1 parent fab59fc commit 44e754b
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation
* @return
*/
private <T> List<Invoker<T>> filterUsingStaticTag(List<Invoker<T>> invokers, URL url, Invocation invocation) {
List<Invoker<T>> result = invokers;
List<Invoker<T>> result;
// Dynamic param
String tag = StringUtils.isEmpty(invocation.getAttachment(TAG_KEY)) ? url.getParameter(TAG_KEY) :
invocation.getAttachment(TAG_KEY);
Expand Down Expand Up @@ -188,19 +188,11 @@ public boolean isForce() {
}

private boolean isForceUseTag(Invocation invocation) {
return Boolean.valueOf(invocation.getAttachment(FORCE_USE_TAG, url.getParameter(FORCE_USE_TAG, "false")));
return Boolean.parseBoolean(invocation.getAttachment(FORCE_USE_TAG, url.getParameter(FORCE_USE_TAG, "false")));
}

private <T> List<Invoker<T>> filterInvoker(List<Invoker<T>> invokers, Predicate<Invoker<T>> predicate) {
boolean filter = false;
for (int i = 0; i < invokers.size(); ++i) {
Invoker<T> invoker = invokers.get(i);
if (!predicate.test(invoker)) {
filter = true;
break;
}
}
if (!filter) {
if (invokers.stream().allMatch(predicate)) {
return invokers;
}

Expand Down

0 comments on commit 44e754b

Please sign in to comment.