Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
3.1.11
Steps to reproduce this issue
- Define a service reference with a specific provider:
@DubboReference(providedBy = "app1")
private APIService apiService;
- Zookeeper has data:
get /dubbo/mapping/com.example.APIService value:app1,app2
- The app1 listener gets destroyed.
- Try to use another service from app1:
@DubboReference(providedBy = "app1")
private API2Service api2Service;
Result: No provider found.
What you expected to happen
The service reference should succeed.
Anything else
- Why is the mapping being looked up when the provider is already specified?
- In the code that handles service instance changes:
if (!oldListener.hasListeners()) {
oldListener.destroy(); // 🪵
removeAppSubscriptionLock(appKey);
}
Is it necessary to remove the oldListener from the serviceListeners Map after it has called destroy?
- Would it be correct to add a line to remove old listeners from serviceListeners, like this:
if (!oldListener.hasListeners()) {
oldListener.destroy();
// Remove old listeners from serviceListeners
serviceListeners.remove(appKey);
removeAppSubscriptionLock(appKey);
}
Are you willing to submit a pull request to fix on your own?
No
Code of Conduct
- I agree to follow this project's Code of Conduct
This consolidated version includes all the key points from your original issue, including the code snippets and your questions about the listener removal process.
3条答案
按热度按时间7jmck4yq1#
Is it necessary to remove the oldListener from the serviceListeners Map after it has called destroy?
fgw7neuy2#
After experimenting, if I add a new lineRemove old listeners from serviceListeners. Is it right to do so?
uqdfh47h3#
PTAL @AlbumenJ