Source:
public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException { if (CollectionUtils.isEmpty(invokers)) { return invokers; } TagRouterRule dump = tagRouterRule; if (dump == null || !dump.isValid() || !dump.isEnabled()) { return filterUsingStaticTag(invokers, url, invocation); } List<Invoker<T>> result = invokers; String tag = StringUtils.isEmpty(invocation.getAttachment(TAG_KEY)) ? url.getParameter(TAG_KEY) : invocation.getAttachment(TAG_KEY); if (StringUtils.isNotEmpty(tag)) { List<String> addresses = dump.getTagnameToAddresses().get(tag); if (CollectionUtils.isNotEmpty(addresses)) { result = filterInvoker(invokers, invoker -> addressMatches(invoker.getUrl(), addresses)); if (CollectionUtils.isNotEmpty(result) || dump.isForce()) { return result; } } else { result = filterInvoker(invokers, invoker -> tag.equals(invoker.getUrl().getParameter(TAG_KEY))); } if (CollectionUtils.isNotEmpty(result) || isForceUseTag(invocation)) { return result; } else { List<Invoker<T>> tmp = filterInvoker(invokers, invoker -> addressNotMatches(invoker.getUrl(), dump.getAddresses())); return filterInvoker(tmp, invoker -> StringUtils.isEmpty(invoker.getUrl().getParameter(TAG_KEY))); } } else { List<String> addresses = dump.getAddresses(); if (CollectionUtils.isNotEmpty(addresses)) { result = filterInvoker(invokers, invoker -> addressNotMatches(invoker.getUrl(), addresses)); if (CollectionUtils.isEmpty(result)) { return result; } } return filterInvoker(result, invoker -> { String localTag = invoker.getUrl().getParameter(TAG_KEY); return StringUtils.isEmpty(localTag) || !dump.getTagNames().contains(localTag); }); } }

Target:
public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException { if (CollectionUtils.isEmpty(invokers)) { return invokers; } final TagRouterRule tagRouterRuleCopy = tagRouterRule; if (tagRouterRuleCopy == null || !tagRouterRuleCopy.isValid() || !tagRouterRuleCopy.isEnabled()) { return filterUsingStaticTag(invokers, url, invocation); } List<Invoker<T>> result = invokers; String tag = StringUtils.isEmpty(invocation.getAttachment(TAG_KEY)) ? url.getParameter(TAG_KEY) : invocation.getAttachment(TAG_KEY); if (StringUtils.isNotEmpty(tag)) { List<String> addresses = tagRouterRuleCopy.getTagnameToAddresses().get(tag); if (CollectionUtils.isNotEmpty(addresses)) { result = filterInvoker(invokers, invoker -> addressMatches(invoker.getUrl(), addresses)); if (CollectionUtils.isNotEmpty(result) || tagRouterRuleCopy.isForce()) { return result; } } else { result = filterInvoker(invokers, invoker -> tag.equals(invoker.getUrl().getParameter(TAG_KEY))); } if (CollectionUtils.isNotEmpty(result) || isForceUseTag(invocation)) { return result; } else { List<Invoker<T>> tmp = filterInvoker(invokers, invoker -> addressNotMatches(invoker.getUrl(), tagRouterRuleCopy.getAddresses())); return filterInvoker(tmp, invoker -> StringUtils.isEmpty(invoker.getUrl().getParameter(TAG_KEY))); } } else { List<String> addresses = tagRouterRuleCopy.getAddresses(); if (CollectionUtils.isNotEmpty(addresses)) { result = filterInvoker(invokers, invoker -> addressNotMatches(invoker.getUrl(), addresses)); if (CollectionUtils.isEmpty(result)) { return result; } } return filterInvoker(result, invoker -> { String localTag = invoker.getUrl().getParameter(TAG_KEY); return StringUtils.isEmpty(localTag) || !tagRouterRuleCopy.getTagNames().contains(localTag); }); } }