From 1e1514063d3d23a1683cea0b3c05b4131d8e61ea Mon Sep 17 00:00:00 2001 From: laywin Date: Thu, 7 Nov 2024 22:29:02 +0800 Subject: [PATCH 1/2] fix judgment for registry configed in DefaultApplicationDeployer --- .../dubbo/config/deploy/DefaultApplicationDeployer.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java index 28940038881..258c0d3c84a 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java @@ -782,14 +782,17 @@ public void prepareApplicationInstance(ModuleModel moduleModel) { // export MetricsService exportMetricsService(); - if (moduleModel.getDeployer().hasRegistryInteraction()) { + boolean registryConfiged = CollectionUtils.isNotEmpty(moduleModel.getApplicationModel(). + getApplicationConfigManager().getRegistries()); + + if (registryConfiged) { ApplicationConfig applicationConfig = configManager.getApplicationOrElseThrow(); if (DEFAULT_APP_NAME.equals(applicationConfig.getName())) { throw new IllegalStateException("Application name must be set when registry is enabled."); } } - if (isRegisterConsumerInstance() || moduleModel.getDeployer().hasRegistryInteraction()) { + if (isRegisterConsumerInstance() || registryConfiged) { if (hasPreparedApplicationInstance.compareAndSet(false, true)) { // register the local ServiceInstance if required registerServiceInstance(); From 02c2f209193db78e0b20c5b323a4a4f774343c24 Mon Sep 17 00:00:00 2001 From: laywin Date: Thu, 7 Nov 2024 23:08:52 +0800 Subject: [PATCH 2/2] format code --- .../dubbo/config/deploy/DefaultApplicationDeployer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java index 258c0d3c84a..9c1e3588c30 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java @@ -782,8 +782,8 @@ public void prepareApplicationInstance(ModuleModel moduleModel) { // export MetricsService exportMetricsService(); - boolean registryConfiged = CollectionUtils.isNotEmpty(moduleModel.getApplicationModel(). - getApplicationConfigManager().getRegistries()); + boolean registryConfiged = CollectionUtils.isNotEmpty( + moduleModel.getApplicationModel().getApplicationConfigManager().getRegistries()); if (registryConfiged) { ApplicationConfig applicationConfig = configManager.getApplicationOrElseThrow();