Skip to content

Commit ced5b71

Browse files
committed
Merge branch 'apache-3.2' into 3.2.0-beta.2-release
2 parents a8af2fe + 5f6a514 commit ced5b71

File tree

2 files changed

+40
-38
lines changed
  • dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration
  • dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency

2 files changed

+40
-38
lines changed

dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,14 @@ private void refreshInvoker(List<URL> invokerUrls) {
232232
}
233233
// use local reference to avoid NPE as this.cachedInvokerUrls will be set null by destroyAllInvokers().
234234
Set<URL> localCachedInvokerUrls = this.cachedInvokerUrls;
235-
if (invokerUrls.isEmpty() && localCachedInvokerUrls != null) {
236-
237-
// 1-4 Empty address.
238-
logger.warn(REGISTRY_EMPTY_ADDRESS, "configuration ", "",
239-
"Service" + serviceKey + " received empty address list with no EMPTY protocol set, trigger empty protection.");
240-
241-
invokerUrls.addAll(localCachedInvokerUrls);
235+
if (invokerUrls.isEmpty()) {
236+
if(CollectionUtils.isNotEmpty(localCachedInvokerUrls)){
237+
// 1-4 Empty address.
238+
logger.warn(REGISTRY_EMPTY_ADDRESS, "configuration ", "",
239+
"Service" + serviceKey + " received empty address list with no EMPTY protocol set, trigger empty protection.");
242240

241+
invokerUrls.addAll(localCachedInvokerUrls);
242+
}
243243
} else {
244244
localCachedInvokerUrls = new HashSet<>();
245245
localCachedInvokerUrls.addAll(invokerUrls);//Cached invoker urls, convenient for comparison

dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void checkDubboBom() throws DocumentException {
8080
.sorted()
8181
.collect(Collectors.toList());
8282

83-
String dubboBomPath = "dubbo-distribution/dubbo-bom/pom.xml";
83+
String dubboBomPath = "dubbo-distribution" + File.separator + "dubbo-bom" + File.separator + "pom.xml";
8484
Document dubboBom = reader.read(new File(getBaseFile(), dubboBomPath));
8585
List<String> artifactIdsInDubboBom = dubboBom.getRootElement()
8686
.element("dependencyManagement")
@@ -120,7 +120,7 @@ void checkDubboDependenciesAll() throws DocumentException {
120120
.sorted()
121121
.collect(Collectors.toList());
122122

123-
String dubboDependenciesAllPath = "dubbo-test/dubbo-dependencies-all/pom.xml";
123+
String dubboDependenciesAllPath = "dubbo-test" + File.separator + "dubbo-dependencies-all" + File.separator + "pom.xml";
124124
Document dubboDependenciesAll = reader.read(new File(getBaseFile(), dubboDependenciesAllPath));
125125
List<String> artifactIdsInDubboDependenciesAll = dubboDependenciesAll.getRootElement()
126126
.element("dependencies")
@@ -177,7 +177,7 @@ void checkDubboAllDependencies() throws DocumentException {
177177
.sorted()
178178
.collect(Collectors.toList());
179179

180-
String dubboAllPath = "dubbo-distribution/dubbo-all/pom.xml";
180+
String dubboAllPath = "dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml";
181181
Document dubboAll = reader.read(new File(getBaseFile(), dubboAllPath));
182182
List<String> artifactIdsInDubboAll = dubboAll.getRootElement()
183183
.element("dependencies")
@@ -191,12 +191,12 @@ void checkDubboAllDependencies() throws DocumentException {
191191
expectedArtifactIds.removeIf(artifactId -> ignoredModules.stream().anyMatch(pattern -> pattern.matcher(artifactId).matches()));
192192
expectedArtifactIds.removeIf(artifactId -> ignoredModulesInDubboAll.stream().anyMatch(pattern -> pattern.matcher(artifactId).matches()));
193193

194-
Assertions.assertTrue(expectedArtifactIds.isEmpty(), "Newly created modules must be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml). Found modules: " + expectedArtifactIds);
194+
Assertions.assertTrue(expectedArtifactIds.isEmpty(), "Newly created modules must be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml). Found modules: " + expectedArtifactIds);
195195

196196
List<String> unexpectedArtifactIds = new LinkedList<>(artifactIdsInDubboAll);
197197
unexpectedArtifactIds.removeIf(artifactId -> !artifactIds.contains(artifactId));
198198
unexpectedArtifactIds.removeAll(deployedArtifactIds);
199-
Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Undeploy dependencies should not be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml). Found modules: " + unexpectedArtifactIds);
199+
Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Undeploy dependencies should not be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml). Found modules: " + unexpectedArtifactIds);
200200

201201
unexpectedArtifactIds = new LinkedList<>();
202202
for (String artifactId : artifactIdsInDubboAll) {
@@ -210,7 +210,7 @@ void checkDubboAllDependencies() throws DocumentException {
210210
unexpectedArtifactIds.add(artifactId);
211211
}
212212
}
213-
Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Unexpected dependencies should not be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml). Found modules: " + unexpectedArtifactIds);
213+
Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Unexpected dependencies should not be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml). Found modules: " + unexpectedArtifactIds);
214214
}
215215

216216
@Test
@@ -254,7 +254,7 @@ void checkDubboAllShade() throws DocumentException {
254254
.sorted()
255255
.collect(Collectors.toList());
256256

257-
String dubboAllPath = "dubbo-distribution/dubbo-all/pom.xml";
257+
String dubboAllPath = "dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml";
258258
Document dubboAll = reader.read(new File(getBaseFile(), dubboAllPath));
259259
List<String> artifactIdsInDubboAll = dubboAll.getRootElement()
260260
.element("build")
@@ -281,12 +281,12 @@ void checkDubboAllShade() throws DocumentException {
281281
expectedArtifactIds.removeIf(artifactId -> ignoredModules.stream().anyMatch(pattern -> pattern.matcher(artifactId).matches()));
282282
expectedArtifactIds.removeIf(artifactId -> ignoredModulesInDubboAll.stream().anyMatch(pattern -> pattern.matcher(artifactId).matches()));
283283

284-
Assertions.assertTrue(expectedArtifactIds.isEmpty(), "Newly created modules must be added to dubbo-all (dubbo-distribution/dubbo-all/pom.xml in shade plugin). Found modules: " + expectedArtifactIds);
284+
Assertions.assertTrue(expectedArtifactIds.isEmpty(), "Newly created modules must be added to dubbo-all (dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin). Found modules: " + expectedArtifactIds);
285285

286286
List<String> unexpectedArtifactIds = new LinkedList<>(artifactIdsInDubboAll);
287287
unexpectedArtifactIds.removeIf(artifactId -> !artifactIds.contains(artifactId));
288288
unexpectedArtifactIds.removeAll(deployedArtifactIds);
289-
Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Undeploy dependencies should not be added to dubbo-all (dubbo-distribution/dubbo-all/pom.xml in shade plugin). Found modules: " + unexpectedArtifactIds);
289+
Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Undeploy dependencies should not be added to dubbo-all (dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin). Found modules: " + unexpectedArtifactIds);
290290

291291
unexpectedArtifactIds = new LinkedList<>();
292292
for (String artifactId : artifactIdsInDubboAll) {
@@ -300,7 +300,7 @@ void checkDubboAllShade() throws DocumentException {
300300
unexpectedArtifactIds.add(artifactId);
301301
}
302302
}
303-
Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Unexpected dependencies should not be added to dubbo-all (dubbo-distribution/dubbo-all/pom.xml in shade plugin). Found modules: " + unexpectedArtifactIds);
303+
Assertions.assertTrue(unexpectedArtifactIds.isEmpty(), "Unexpected dependencies should not be added to dubbo-all (dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin). Found modules: " + unexpectedArtifactIds);
304304
}
305305

306306
@Test
@@ -309,7 +309,7 @@ void checkDubboAllTransform() throws DocumentException {
309309
List<String> spis = new LinkedList<>();
310310
readSPI(baseFile, spis);
311311

312-
String dubboAllPath = "dubbo-distribution/dubbo-all/pom.xml";
312+
String dubboAllPath = "dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml";
313313

314314
SAXReader reader = new SAXReader();
315315
Document dubboAll = reader.read(new File(baseFile, dubboAllPath));
@@ -335,11 +335,11 @@ void checkDubboAllTransform() throws DocumentException {
335335

336336
List<String> expectedSpis = new LinkedList<>(spis);
337337
expectedSpis.removeAll(transformsInDubboAll);
338-
Assertions.assertTrue(expectedSpis.isEmpty(), "Newly created SPI interface must be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml in shade plugin) to being transformed. Found spis: " + expectedSpis);
338+
Assertions.assertTrue(expectedSpis.isEmpty(), "Newly created SPI interface must be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin) to being transformed. Found spis: " + expectedSpis);
339339

340340
List<String> unexpectedSpis = new LinkedList<>(transformsInDubboAll);
341341
unexpectedSpis.removeAll(spis);
342-
Assertions.assertTrue(unexpectedSpis.isEmpty(), "Class without `@SPI` declaration should not be added to dubbo-all(dubbo-distribution/dubbo-all/pom.xml in shade plugin) to being transformed. Found spis: " + unexpectedSpis);
342+
Assertions.assertTrue(unexpectedSpis.isEmpty(), "Class without `@SPI` declaration should not be added to dubbo-all(dubbo-distribution" + File.separator + "dubbo-all" + File.separator + "pom.xml in shade plugin) to being transformed. Found spis: " + unexpectedSpis);
343343
}
344344

345345
@Test
@@ -356,8 +356,8 @@ void checkSpiFiles() {
356356

357357
List<File> unexpectedSpis = new LinkedList<>();
358358
readSPIUnexpectedResource(baseFile, unexpectedSpis);
359-
unexpectedSpis.removeIf(file -> file.getAbsolutePath().contains("dubbo-common/src/main/resources/META-INF/services/org.apache.dubbo.common.extension.LoadingStrategy"));
360-
Assertions.assertTrue(unexpectedSpis.isEmpty(), "Dubbo native provided spi profiles must filed in `META-INF/dubbo/internal`. Please move to proper folder . Found spis: " + unexpectedSpis);
359+
unexpectedSpis.removeIf(file -> file.getAbsolutePath().contains("dubbo-common" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "services" + File.separator + "org.apache.dubbo.common.extension.LoadingStrategy"));
360+
Assertions.assertTrue(unexpectedSpis.isEmpty(), "Dubbo native provided spi profiles must filed in `META-INF" + File.separator + "dubbo" + File.separator + "internal`. Please move to proper folder . Found spis: " + unexpectedSpis);
361361
}
362362

363363
private static File getBaseFile() {
@@ -404,7 +404,7 @@ public void readSPI(File path, List<String> spis) {
404404
if (path.getAbsolutePath().contains("target")) {
405405
return;
406406
}
407-
if (path.getAbsolutePath().contains("src/main/java")) {
407+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "java")) {
408408
String content;
409409
try {
410410
content = FileUtils.readFileToString(path, StandardCharsets.UTF_8);
@@ -413,9 +413,10 @@ public void readSPI(File path, List<String> spis) {
413413
}
414414
if (content != null && content.contains("@SPI")) {
415415
String absolutePath = path.getAbsolutePath();
416-
absolutePath = absolutePath.substring(absolutePath.lastIndexOf("src/main/java/") + "src/main/java/".length());
416+
absolutePath = absolutePath.substring(absolutePath.lastIndexOf("src" + File.separator + "main" + File.separator + "java" + File.separator)
417+
+ ("src" + File.separator + "main" + File.separator + "java" + File.separator).length());
417418
absolutePath = absolutePath.substring(0, absolutePath.lastIndexOf(".java"));
418-
absolutePath = absolutePath.replaceAll("/", ".");
419+
absolutePath = absolutePath.replaceAll(File.separator, ".");
419420
spis.add(absolutePath);
420421
}
421422
}
@@ -434,10 +435,11 @@ public void readSPIResource(File path, Map<File, String> spis) {
434435
if (path.getAbsolutePath().contains("target")) {
435436
return;
436437
}
437-
if (path.getAbsolutePath().contains("src/main/resources/META-INF/dubbo/internal/")) {
438+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "internal" + File.separator)) {
438439
String absolutePath = path.getAbsolutePath();
439-
absolutePath = absolutePath.substring(absolutePath.lastIndexOf("src/main/resources/META-INF/dubbo/internal/") + "src/main/resources/META-INF/dubbo/internal/".length());
440-
absolutePath = absolutePath.replaceAll("/", ".");
440+
absolutePath = absolutePath.substring(absolutePath.lastIndexOf("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "internal" + File.separator)
441+
+ ("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "internal" + File.separator).length());
442+
absolutePath = absolutePath.replaceAll( File.separator, ".");
441443
spis.put(path, absolutePath);
442444
}
443445
}
@@ -455,35 +457,35 @@ public void readSPIUnexpectedResource(File path, List<File> spis) {
455457
if (path.getAbsolutePath().contains("target")) {
456458
return;
457459
}
458-
if (path.getAbsolutePath().contains("src/main/resources/META-INF/dubbo/org.apache.dubbo")) {
460+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "org.apache.dubbo")) {
459461
spis.add(path);
460462
}
461-
if (path.getAbsolutePath().contains("src/main/resources/META-INF/dubbo/com.alibaba.dubbo")) {
463+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "dubbo" + File.separator + "com.alibaba.dubbo")) {
462464
spis.add(path);
463465
}
464-
if (path.getAbsolutePath().contains("src/main/resources/META-INF/services/org.apache.dubbo")) {
466+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "services" + File.separator + "org.apache.dubbo")) {
465467
spis.add(path);
466468
}
467-
if (path.getAbsolutePath().contains("src/main/resources/META-INF/services/com.alibaba.dubbo")) {
469+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF" + File.separator + "services" + File.separator + "com.alibaba.dubbo")) {
468470
spis.add(path);
469471
}
470472

471-
if (path.getAbsolutePath().contains("src/main/resources/META-INF.dubbo/org.apache.dubbo")) {
473+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.dubbo" + File.separator + "org.apache.dubbo")) {
472474
spis.add(path);
473475
}
474-
if (path.getAbsolutePath().contains("src/main/resources/META-INF.dubbo/com.alibaba.dubbo")) {
476+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.dubbo" + File.separator + "com.alibaba.dubbo")) {
475477
spis.add(path);
476478
}
477-
if (path.getAbsolutePath().contains("src/main/resources/META-INF.services/org.apache.dubbo")) {
479+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.services" + File.separator + "org.apache.dubbo")) {
478480
spis.add(path);
479481
}
480-
if (path.getAbsolutePath().contains("src/main/resources/META-INF.services/com.alibaba.dubbo")) {
482+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.services" + File.separator + "com.alibaba.dubbo")) {
481483
spis.add(path);
482484
}
483-
if (path.getAbsolutePath().contains("src/main/resources/META-INF.dubbo.internal/org.apache.dubbo")) {
485+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.dubbo.internal" + File.separator + "org.apache.dubbo")) {
484486
spis.add(path);
485487
}
486-
if (path.getAbsolutePath().contains("src/main/resources/META-INF.dubbo.internal/com.alibaba.dubbo")) {
488+
if (path.getAbsolutePath().contains("src" + File.separator + "main" + File.separator + "resources" + File.separator + "META-INF.dubbo.internal" + File.separator + "com.alibaba.dubbo")) {
487489
spis.add(path);
488490
}
489491
}

0 commit comments

Comments
 (0)