onceMisery opened a new issue, #16108: URL: https://github.com/apache/dubbo/issues/16108
### Pre-check - [x] 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 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 ```yaml dubbo: protocol: port: yourPort serialization: fastjson2 consumer: protocol: dubbo protocols: dubbo: name: dubbo port: yourPort serialization: fastjson2 timeout: 30000 ``` ### Steps 1. Register a Spring Cloud service (non-Dubbo) to Nacos. 2. Register a Dubbo consumer application to the same Nacos namespace. 3. The Dubbo consumer has `@DubboReference` on an interface (e.g., `TestApi`) that shares the same application name as the Spring Cloud service. 4. 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.TenantDictApi, 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 three components working together incorrectly: **1. `SpringCloudServiceInstanceNotificationCustomizer.customize()`** sets REST protocol metadata on Spring Cloud instances with a wildcard path `"*"`: ```java 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: ```java // 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? - [x] 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? - [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) -- 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]
