From 6b3b017209f7d3f8fb2bcc16615a3fe618935a1e Mon Sep 17 00:00:00 2001 From: mercyblitz Date: Tue, 4 Feb 2020 13:51:00 +0800 Subject: [PATCH] Polish alibaba/spring-cloud-alibaba/#1132 : [Nacos Discovery] NacosServiceRegistry throw Exception when register failed --- .../alibaba/cloud/nacos/registry/NacosServiceRegistry.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-cloud-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosServiceRegistry.java b/spring-cloud-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosServiceRegistry.java index af81f0ac..b0974a55 100644 --- a/spring-cloud-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosServiceRegistry.java +++ b/spring-cloud-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosServiceRegistry.java @@ -28,6 +28,8 @@ import org.springframework.cloud.client.serviceregistry.Registration; import org.springframework.cloud.client.serviceregistry.ServiceRegistry; import org.springframework.util.StringUtils; +import static org.springframework.util.ReflectionUtils.rethrowRuntimeException; + /** * @author xiaojing * @author Mercy @@ -66,6 +68,9 @@ public class NacosServiceRegistry implements ServiceRegistry { catch (Exception e) { log.error("nacos registry, {} register failed...{},", serviceId, registration.toString(), e); + // rethrow a RuntimeException if the registration is failed. + // issue : https://github.com/alibaba/spring-cloud-alibaba/issues/1132 + rethrowRuntimeException(e); } }