From 7629b0f72c66002a4bcfa6235329f58783b3240f Mon Sep 17 00:00:00 2001 From: xujingfeng Date: Sat, 29 Dec 2018 18:06:58 +0800 Subject: [PATCH] remove try catch --- .../rpc/cluster/router/tag/TagRouter.java | 46 ++++++++----------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java index a5092bfa2570..62f1811ff30e 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java @@ -62,40 +62,34 @@ public URL getUrl() { public List> route(List> invokers, URL url, Invocation invocation) throws RpcException { // filter List> 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 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 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 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 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 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