Skip to content

Commit c831fef

Browse files
zrlwsongxiaosheng
andauthored
Add serviceConfigV2 null check at metadata service export (#15603)
* Remove redundant condition checking from ConfigurableMetadataServiceExporter method --------- Co-authored-by: xiaosheng <songxiaosheng@apache.org>
1 parent 8dabe60 commit c831fef

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/metadata/ConfigurableMetadataServiceExporter.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.dubbo.config.metadata;
1818

19+
import org.apache.dubbo.common.URL;
1920
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
2021
import org.apache.dubbo.common.logger.LoggerFactory;
2122
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
@@ -31,6 +32,7 @@
3132
import org.apache.dubbo.registry.client.metadata.MetadataServiceDelegationV2;
3233
import org.apache.dubbo.rpc.model.ApplicationModel;
3334

35+
import java.util.ArrayList;
3436
import java.util.Collections;
3537
import java.util.List;
3638
import java.util.concurrent.ExecutorService;
@@ -71,7 +73,7 @@ public ConfigurableMetadataServiceExporter(
7173
}
7274

7375
public synchronized ConfigurableMetadataServiceExporter export() {
74-
if (serviceConfig == null || !isExported()) {
76+
if (!isExported()) {
7577
if (MetadataServiceVersionUtils.needExportV1(applicationModel)) {
7678
exportV1();
7779
}
@@ -84,13 +86,28 @@ public synchronized ConfigurableMetadataServiceExporter export() {
8486
CONFIG_METADATA_SERVICE_EXPORTED,
8587
"",
8688
"",
87-
"The MetadataService has been exported : " + serviceConfig.getExportedUrls());
89+
"The MetadataService has been exported : " + getExportedUrls());
8890
}
8991
}
9092

9193
return this;
9294
}
9395

96+
/**
97+
* Get exported urls which include v1 and v2 if existed
98+
* @return exported urls
99+
*/
100+
public List<URL> getExportedUrls() {
101+
List<URL> urls = new ArrayList<>();
102+
if (serviceConfig != null) {
103+
urls.addAll(serviceConfig.getExportedUrls());
104+
}
105+
if (serviceConfigV2 != null) {
106+
urls.addAll(serviceConfigV2.getExportedUrls());
107+
}
108+
return urls;
109+
}
110+
94111
private static final String INTERNAL_METADATA_REGISTRY_ID = "internal-metadata-registry";
95112

96113
private void exportV1() {

0 commit comments

Comments
 (0)