iwangjie commented on issue #14479:
URL: https://github.com/apache/dubbo/issues/14479#issuecomment-2274790870
> Thanks for the detailed information, I see the problem here. How to
guarantee the priority of `providedBy` need to be further investigated.
>
> Have you tried the latest 3.2.14 or 3.2.15 release? I think even if
`providedBy` gets overridden unexpectedly, it should not report `no provider`
exception, it should still has available providers, only the providers change
from `app1` to `app1,app2`
I can provide an additional piece of information that I think is quite
crucial: the timing of reference loading seems to conflict with the Mapping
listener. Let me give you an example.
First, we define two references to different interfaces of the same App. Due
to the loading order and internal mechanisms, after UserService is injected,
the Mapping listener happens to send a MappingChangeEvent that internally
destroys the listener for app1 (though it doesn’t remove it). When PicService
is loaded, it specifies `providedBy`, so it retrieves the destroyed listener
from the Mapping cache. Since the listener is already destroyed, nothing
happens, and the registration is ignored.
@DubboReference(providedBy = "app1")
private UserService userService;
@DubboReference(providedBy = "app1")
private PicService picService;
```java
@Override
public synchronized void initInterfaceAppMapping(URL subscribedURL) {
String key = ServiceNameMapping.buildMappingKey(subscribedURL);
if (hasInitiated(key)) {
return;
}
mappingInitStatus.put(key, Boolean.TRUE);
Set<String> subscribedServices = new TreeSet<>();
String serviceNames = subscribedURL.getParameter(PROVIDED_BY); // ⚠️
Pay attention here
if (StringUtils.isNotEmpty(serviceNames)) {
logger.info(key + " mapping to " + serviceNames + " instructed
by provided-by set by user.");
subscribedServices.addAll(parseServices(serviceNames));
}
if (isEmpty(subscribedServices)) {
Set<String> cachedServices = this.getCachedMapping(key);
if (!isEmpty(cachedServices)) {
logger.info(key + " mapping to " + serviceNames + "
instructed by local cache.");
subscribedServices.addAll(cachedServices);
}
} else {
this.putCachedMappingIfAbsent(key, subscribedServices);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]