This is an automated email from the ASF dual-hosted git repository. albumenj pushed a commit to branch 3.2 in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push: new 342121ccc2 fix: Resolved issue where ServiceInfo with null protocol was blocking the refresh of invokers (#14421) 342121ccc2 is described below commit 342121ccc2cc49a0338f9d6ad944db5cb85d2958 Author: QingJuBaiTang <295168...@qq.com> AuthorDate: Tue Jul 16 17:43:16 2024 +0800 fix: Resolved issue where ServiceInfo with null protocol was blocking the refresh of invokers (#14421) --- ...ringCloudServiceInstanceNotificationCustomizer.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SpringCloudServiceInstanceNotificationCustomizer.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SpringCloudServiceInstanceNotificationCustomizer.java index e0509b0a37..44b32b6a68 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SpringCloudServiceInstanceNotificationCustomizer.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SpringCloudServiceInstanceNotificationCustomizer.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; public class SpringCloudServiceInstanceNotificationCustomizer implements ServiceInstanceNotificationCustomizer { + private static final String REST_PROTOCOL = "rest"; + @Override public void customize(List<ServiceInstance> serviceInstance) { if (serviceInstance.isEmpty()) { @@ -38,8 +40,8 @@ public class SpringCloudServiceInstanceNotificationCustomizer implements Service } for (ServiceInstance instance : serviceInstance) { - MetadataInfo.ServiceInfo serviceInfo = - new MetadataInfo.ServiceInfo("*", "*", "*", "rest", instance.getPort(), "*", new HashMap<>()); + MetadataInfo.ServiceInfo serviceInfo = new MetadataInfo.ServiceInfo( + "*", "*", "*", REST_PROTOCOL, instance.getPort(), "*", new HashMap<>()); String revision = "SPRING_CLOUD-" + instance.getServiceName() + "-" + instance.getAddress() + "-" + instance.getPort(); MetadataInfo metadataInfo = @@ -49,6 +51,16 @@ public class SpringCloudServiceInstanceNotificationCustomizer implements Service new ConcurrentHashMap<>(Collections.singletonMap("*", serviceInfo))) { @Override public List<ServiceInfo> getMatchedServiceInfos(ProtocolServiceKey consumerProtocolServiceKey) { + String consumerProtocol = consumerProtocolServiceKey.getProtocol(); + if (consumerProtocol != null && !REST_PROTOCOL.equalsIgnoreCase(consumerProtocol)) { + return Collections.emptyList(); + } + + String protocol = consumerProtocol; + if (protocol == null) { + protocol = REST_PROTOCOL; + } + getServices() .putIfAbsent( consumerProtocolServiceKey.getServiceKeyString(), @@ -56,7 +68,7 @@ public class SpringCloudServiceInstanceNotificationCustomizer implements Service consumerProtocolServiceKey.getInterfaceName(), consumerProtocolServiceKey.getGroup(), consumerProtocolServiceKey.getVersion(), - consumerProtocolServiceKey.getProtocol(), + protocol, instance.getPort(), consumerProtocolServiceKey.getInterfaceName(), new HashMap<>()));