Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when the TagRouterRule addresses config is null #4218

Closed
2 tasks done
web1992 opened this issue May 31, 2019 · 3 comments
Closed
2 tasks done

NPE when the TagRouterRule addresses config is null #4218

web1992 opened this issue May 31, 2019 · 3 comments

Comments

@web1992
Copy link
Contributor

web1992 commented May 31, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.1
  • Operating System version: Windows
  • Java version: 1.8

Steps to reproduce this issue

When I config TagRouter like this (in Dubbo admin):

enabled: true
force: false
runtime: false
tags:
  - name: tag1
    addresses: null
  - name: tag2
    addresses: null

Actual Result

Then the java.lang.NullPointerException was caused

java.lang.NullPointerException
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRouterRule.lambda$init$2(TagRouterRule.java:55)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRouterRule.init(TagRouterRule.java:53)
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRuleParser.parse(TagRuleParser.java:42)

I think we should add NPE check in TagRouterRule or check addresses in Dubbo admin

tags.forEach(tag -> {
    tagnameToAddresses.put(tag.getName(), tag.getAddresses());
   // check  tag.getAddresses() not null
    tag.getAddresses().forEach(addr -> {
        List<String> tagNames = addressToTagnames.computeIfAbsent(addr, k -> new ArrayList<>());
        tagNames.add(tag.getName());
    });
});
@CrazyHZM
Copy link
Member

CrazyHZM commented Jun 3, 2019

Can you submit a PR to fix it?

@web1992
Copy link
Contributor Author

web1992 commented Jun 3, 2019

@CrazyHZM I have send one PR

CrazyHZM pushed a commit that referenced this issue Jun 3, 2019
…4218) (#4236)

* Fix NPE when the TagRouterRule addresses config is null (#4218)

* fix import

* add more test
@CrazyHZM
Copy link
Member

CrazyHZM commented Jun 3, 2019

Thank you, I have already dealt with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants