Skip to content

Commit

Permalink
remove try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
xujingfeng committed Dec 29, 2018
1 parent eccb7b4 commit 7629b0f
Showing 1 changed file with 20 additions and 26 deletions.
Expand Up @@ -62,40 +62,34 @@ public URL getUrl() {
public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException {
// filter
List<Invoker<T>> result = new ArrayList<>();
try {
// Dynamic param
String tag = RpcContext.getContext().getAttachment(Constants.TAG_KEY);
// Tag request
if (!StringUtils.isEmpty(tag)) {
// Select tag invokers first
for (Invoker<T> invoker : invokers) {
if (tag.equals(invoker.getUrl().getParameter(Constants.TAG_KEY))) {
result.add(invoker);
}
}
// If no invoker be selected, downgrade to normal invokers
if (result.isEmpty()) {
for (Invoker<T> invoker : invokers) {
if (StringUtils.isEmpty(invoker.getUrl().getParameter(Constants.TAG_KEY))) {
result.add(invoker);
}
}
// Dynamic param
String tag = RpcContext.getContext().getAttachment(Constants.TAG_KEY);
// Tag request
if (!StringUtils.isEmpty(tag)) {
// Select tag invokers first
for (Invoker<T> invoker : invokers) {
if (tag.equals(invoker.getUrl().getParameter(Constants.TAG_KEY))) {
result.add(invoker);
}
// Normal request
} else {
}
// If no invoker be selected, downgrade to normal invokers
if (result.isEmpty()) {
for (Invoker<T> invoker : invokers) {
// Can't access tag invoker,only normal invoker should be selected
if (StringUtils.isEmpty(invoker.getUrl().getParameter(Constants.TAG_KEY))) {
result.add(invoker);
}
}
}
return result;
} catch (Exception e) {
logger.error("Route by tag error,return all invokers.", e);
// Normal request
} else {
for (Invoker<T> invoker : invokers) {
// Can't access tag invoker,only normal invoker should be selected
if (StringUtils.isEmpty(invoker.getUrl().getParameter(Constants.TAG_KEY))) {
result.add(invoker);
}
}
}
// Downgrade to all invokers
return invokers;
return result;
}

@Override
Expand Down

0 comments on commit 7629b0f

Please sign in to comment.