-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Description
Pre-check
- I am sure that all the content I provide is in English.
Search before asking
- I had searched in the issues and found no similar issues.
Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
Dubbo version 3.2.x , openJdk 17 , Ubuntu20.04
Steps to reproduce this issue
Environment
- Dubbo version: 3.2.x (tested on 3.2.18 / 3.2.19)
- Registry: Nacos
- Spring Cloud and Dubbo services registered under the same Nacos namespace
Configuration
dubbo:
protocol:
port: yourPort
serialization: fastjson2
consumer:
protocol: dubbo
protocols:
dubbo:
name: dubbo
port: yourPort
serialization: fastjson2
timeout: 30000Steps
- Register a Spring Cloud service (non-Dubbo) to Nacos.
- Register a Dubbo consumer application to the same Nacos namespace.
- The Dubbo consumer has
@DubboReferenceon an interface (e.g.,TestApi) that shares the same application name as the Spring Cloud service. - Start the Dubbo consumer application.
Error logs
[DUBBO] Failed to refer invoker for interface: interface com.example.TestApi,
url:(DefaultServiceInstance{serviceName='example-service', host='172.23.45.123', port=11105,
enabled=true, healthy=true, metadata={preserved.register.source=SPRING_CLOUD}},
service{name='com.example.TestApi', group='null', version='null', protocol='rest',
port='TestApiServiceRestPort', params={},})
service is: interface com.example.TestApi, only support [jax-rs, spring-webmvc] annotation,
dubbo version: 3.2.19, error code: 4-3.
[DUBBO] Unsupported protocol., dubbo version: 3.2.19, error code: 4-1.
java.lang.IllegalStateException: Cannot create invokers from url address list (total 1)
at o.a.d.registry.client.ServiceDiscoveryRegistryDirectory.refreshInvoker(ServiceDiscoveryRegistryDirectory.java:376)
What you expected to happen
When a Dubbo consumer discovers Spring Cloud instances (which have no Dubbo metadata), it should gracefully skip those instances instead of throwing IllegalStateException. The consumer should wait for actual Dubbo provider instances to register.
Anything else
Root cause analysis
The issue involves two primary components working together incorrectly:
1. SpringCloudServiceInstanceNotificationCustomizer.customize() sets REST protocol metadata on Spring Cloud instances with a wildcard path "*":
MetadataInfo.ServiceInfo serviceInfo = new MetadataInfo.ServiceInfo(
"*", "*", "*", REST_PROTOCOL, instance.getPort(), "*", new HashMap<>());2. SpringCloudServiceInstanceNotificationCustomizer inner MetadataInfo.getMatchedServiceInfos() only filters out non-REST consumers when consumerProtocol != null. When @DubboReference does not explicitly specify protocol, the consumerProtocolServiceKey.getProtocol() is null, bypassing the filter:
// Original code: null protocol falls through to REST matching
if (consumerProtocol != null && !REST_PROTOCOL.equalsIgnoreCase(consumerProtocol)) {
return Collections.emptyList();
}Do you have a (mini) reproduction demo?
- Yes, I have a minimal reproduction demo to help resolve this issue more effectively!
Are you willing to submit a pull request to fix on your own?
- Yes I am willing to submit a pull request on my own!
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status