Skip to content

[Issue] The TagRouter maybe have one issue #5971

@Hinsteny

Description

@Hinsteny
  • [ X] I have searched the issues of this repository and believe that this is not a duplicate.
  • [ X] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.7
  • Operating System version: macOS
  • Java version: 1.8

Steps to reproduce this issue

  1. Two provider service with same interface [GreetingsService] and different service-port and provider-tag[dubbo-tag=grey];--- Provider-A(no tag), Provider-B(with tag),
  2. Start one Consumer to call the GreetingsService with no tag; --- Consumer-X(no tag),

Expected Result

What do you expected from the above steps?

I think and need the consumer to call the provider with no tag grey;

Actual Result

What actually happens?

The consumer always call the provider with tag grey;

Reason

When dubbo initial the consumer service reference, it will merge the all provider Parameters to the consumer Parameter map; then do the provider select will use the provider's tag to select provider;

TagRouter

   @Override
    public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException {
        if (CollectionUtils.isEmpty(invokers)) {
            return invokers;
        }

        // since the rule can be changed by config center, we should copy one to use.
        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 we are requesting for a Provider with a specific tag
        if (StringUtils.isNotEmpty(tag)) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions