apache / apache/dubbo

[Bug] dubbo Provider列表变更通知consumer 消费端 出现NullPointerException bug

Open
#14,196 1 comment 0 reactions 0 assignees View on GitHub
component/need-triage type/need-triage
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

### Pre-check

- [ ] I am sure that all the content I provide is in English.

### Search before asking

- [X] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues.

### Apache Dubbo Component

Java SDK (apache/dubbo)

### Dubbo Version

Dubbo 3.2.11 JDK 17

### Steps to reproduce this issue

上线发布 Dubbo 服务提供者,服务提供者和消费者都只有一个POD实例

### What you expected to happen

_time_: 2024-05-16T10:17:12.878479339+08:00
content: 2024-05-16 10:17:12,877 ERROR [nacos.publisher-com.alibaba.nacos.client.naming.event.InstancesChangeEvent] [TRACEID:] [c.a.n.c.n.NotifyCenter:208]}: Event callback exception:
java.lang.NullPointerException: null
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1693) ~[?:?]
at org.apache.dubbo.registry.client.DefaultServiceInstance.toURL(DefaultServiceInstance.java:294) ~[dubbo-3.2.11.jar!/:3.2.11]
at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.getServiceUrlsCache(ServiceInstancesChangedListener.java:407) ~[dubbo-3.2.11.jar!/:3.2.11]
at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.lambda$doOnEvent$5(ServiceInstancesChangedListener.java:234) ~[dubbo-3.2.11.jar!/:3.2.11]
at java.util.HashMap.computeIfAbsent(HashMap.java:1220) ~[?:?]
at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.doOnEvent(ServiceInstancesChangedListener.java:232) ~[dubbo-3.2.11.jar!/:3.2.11]
at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.onEvent(ServiceInstancesChangedListener.java:125) ~[dubbo-3.2.11.jar!/:3.2.11]
at org.apache.dubbo.registry.nacos.NacosServiceDiscovery.handleEvent(NacosServiceDiscovery.java:245) ~[dubbo-3.2.11.jar!/:3.2.11]
at org.apache.dubbo.registry.nacos.NacosServiceDiscovery.access$000(NacosServiceDiscovery.java:65) ~[dubbo-3.2.11.jar!/:3.2.11]
at org.apache.dubbo.registry.nacos.NacosServiceDiscovery$NacosEventListener.onEvent(NacosServiceDiscovery.java:217) ~[dubbo-3.2.11.jar!/:3.2.11]
at com.alibaba.nacos.client.naming.event.InstancesChangeNotifier.onEvent(InstancesChangeNotifier.java:126) ~[nacos-client-2.2.1.jar!/:?]
at com.alibaba.nacos.client.naming.event.InstancesChangeNotifier.onEvent(InstancesChangeNotifier.java:42) ~[nacos-client-2.2.1.jar!/:?]
at com.alibaba.nacos.common.notify.DefaultPublisher.lambda$notifySubscriber$0(DefaultPublisher.java:199) ~[nacos-client-2.2.1.jar!/:?]
at com.alibaba.nacos.common.notify.DefaultPublisher.notifySubscriber(DefaultPublisher.java:206) [nacos-client-2.2.1.jar!/:?]
at com.alibaba.nacos.common.notify.DefaultPublisher.receiveEvent(DefaultPublisher.java:190) [nacos-client-2.2.1.jar!/:?]
at com.alibaba.nacos.common.notify.DefaultPublisher.openEventHandler(DefaultPublisher.java:112) [nacos-client-2.2.1.jar!/:?]
at com.alibaba.nacos.common.notify.DefaultPublisher.run(DefaultPublisher.java:95) [nacos-client-2.2.1.jar!/:?]

### Anything else

_No response_

### Are you willing to submit a pull request to fix on your own?

- [X] Yes I am willing to submit a pull request on my own!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

Contributor guide

Open the contributing guide

Research direction

Reproduce the provider-list change with one provider and one consumer POD on Dubbo 3.2.11 with JDK 17. Start at DefaultServiceInstance.toURL and follow ServiceInstancesChangedListener.getServiceUrlsCache, doOnEvent, and NacosServiceDiscovery.handleEvent from the reported stack trace. Done means the consumer processes the provider change without the reported NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.