- dubbo-parent
org.apache.dubbo
+ dubbo-parent
${revision}
+ ../pom.xml
4.0.0
diff --git a/dubbo-registry/dubbo-registry-api/pom.xml b/dubbo-registry/dubbo-registry-api/pom.xml
index 86583e2ae7..db0c17586e 100644
--- a/dubbo-registry/dubbo-registry-api/pom.xml
+++ b/dubbo-registry/dubbo-registry-api/pom.xml
@@ -21,6 +21,7 @@
org.apache.dubbo
dubbo-registry
${revision}
+ ../pom.xml
dubbo-registry-api
jar
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceInstance.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceInstance.java
index 9949bab20d..251372d033 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceInstance.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceInstance.java
@@ -16,19 +16,8 @@
*/
package org.apache.dubbo.registry.client;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.URLBuilder;
-import org.apache.dubbo.metadata.MetadataService;
-
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
-import static java.lang.String.valueOf;
-import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getMetadataServiceURLsParams;
-import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getProviderHost;
-import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getProviderPort;
-
/**
* The model class of an instance of a service, which is used for service registration and discovery.
*
@@ -103,36 +92,4 @@ public interface ServiceInstance {
*/
boolean equals(Object another);
- /**
- * Build the {@link URL urls} from {@link ServiceInstance#getMetadata() the metadata} of {@link ServiceInstance}
- *
- * @param serviceInstance {@link ServiceInstance}
- * @return the not-null {@link List}
- */
- static List toUrls(ServiceInstance serviceInstance) {
-
- Map> paramsMap = getMetadataServiceURLsParams(serviceInstance);
-
- List urls = new ArrayList<>(paramsMap.size());
-
- for (Map.Entry> entry : paramsMap.entrySet()) {
-
- URLBuilder urlBuilder = new URLBuilder();
- String protocol = entry.getKey();
- Map urlParams = entry.getValue();
- String host = getProviderHost(urlParams);
- Integer port = getProviderPort(urlParams);
- urlBuilder.setHost(host)
- .setPort(port)
- .setProtocol(protocol)
- .setPath(MetadataService.class.getName());
-
- // add parameters
- entry.getValue().forEach((name, value) -> urlBuilder.addParameter(name, valueOf(value)));
-
- urls.add(urlBuilder.build());
- }
-
- return urls;
- }
}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/CompositeMetadataServiceURLBuilder.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/CompositeMetadataServiceURLBuilder.java
new file mode 100644
index 0000000000..9ced03aed3
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/CompositeMetadataServiceURLBuilder.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.registry.client.metadata;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.metadata.MetadataService;
+import org.apache.dubbo.registry.client.ServiceInstance;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+import static java.util.Collections.emptyList;
+import static java.util.Collections.unmodifiableList;
+import static java.util.ServiceLoader.load;
+import static org.apache.dubbo.common.utils.CollectionUtils.isNotEmpty;
+
+/**
+ * The implementation of {@link MetadataServiceURLBuilder} composites the multiple {@link MetadataServiceURLBuilder}
+ * instances are loaded by Java standard {@link ServiceLoader} will aggregate {@link URL URLs} for
+ * {@link MetadataServiceProxy}
+ *
+ * @see MetadataServiceURLBuilder
+ * @see MetadataServiceProxy
+ * @see MetadataService
+ * @see URL
+ * @see ServiceLoader
+ * @since 2.7.4
+ */
+class CompositeMetadataServiceURLBuilder implements MetadataServiceURLBuilder {
+
+ private final Class builderClass;
+
+ private final Iterator builders;
+
+ private final ClassLoader classLoader;
+
+ public CompositeMetadataServiceURLBuilder() {
+ this.builderClass = MetadataServiceURLBuilder.class;
+ this.classLoader = getClass().getClassLoader();
+ this.builders = initBuilders();
+ }
+
+ private Iterator initBuilders() {
+ return load(builderClass, classLoader).iterator();
+ }
+
+ @Override
+ public List build(ServiceInstance serviceInstance) {
+ if (serviceInstance == null) {
+ return emptyList();
+ }
+
+ List allURLs = new LinkedList<>();
+
+ while (builders.hasNext()) {
+ MetadataServiceURLBuilder builder = builders.next();
+ List urls = builder.build(serviceInstance);
+ if (isNotEmpty(urls)) {
+ allURLs.addAll(urls);
+ }
+ }
+
+ return unmodifiableList(allURLs);
+ }
+}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ExportedServicesRevisionMetadataCustomizer.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ExportedServicesRevisionMetadataCustomizer.java
index 920096a00b..188312edab 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ExportedServicesRevisionMetadataCustomizer.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ExportedServicesRevisionMetadataCustomizer.java
@@ -25,7 +25,7 @@ import org.apache.dubbo.registry.client.ServiceInstanceMetadataCustomizer;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
+import java.util.SortedSet;
import static java.lang.String.valueOf;
import static java.util.Objects.hash;
@@ -48,7 +48,7 @@ public class ExportedServicesRevisionMetadataCustomizer extends ServiceInstanceM
@Override
protected String buildMetadataValue(ServiceInstance serviceInstance) {
WritableMetadataService writableMetadataService = WritableMetadataService.getDefaultExtension();
- List exportedURLs = writableMetadataService.getExportedURLs();
+ SortedSet exportedURLs = writableMetadataService.getExportedURLs();
Object[] data = exportedURLs.stream()
.map(URL::valueOf) // String to URL
.map(URL::getServiceInterface) // get the service interface
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceProxy.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceProxy.java
index e22b2b80bb..45ce42a041 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceProxy.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceProxy.java
@@ -27,10 +27,11 @@ import org.apache.dubbo.rpc.proxy.InvokerInvocationHandler;
import java.util.Iterator;
import java.util.List;
+import java.util.SortedSet;
import java.util.function.Function;
import static java.lang.reflect.Proxy.newProxyInstance;
-import static org.apache.dubbo.registry.client.metadata.MetadataServiceURLBuilder.INSTANCE;
+import static org.apache.dubbo.registry.client.metadata.MetadataServiceURLBuilder.composite;
/**
* The Proxy object for the {@link MetadataService} whose {@link ServiceInstance} providers may export multiple
@@ -49,7 +50,7 @@ class MetadataServiceProxy implements MetadataService {
private final Protocol protocol;
public MetadataServiceProxy(ServiceInstance serviceInstance, Protocol protocol) {
- this(INSTANCE.build(serviceInstance), protocol);
+ this(composite().build(serviceInstance), protocol);
}
public MetadataServiceProxy(List urls, Protocol protocol) {
@@ -63,12 +64,12 @@ class MetadataServiceProxy implements MetadataService {
}
@Override
- public List getSubscribedURLs() {
+ public SortedSet getSubscribedURLs() {
return doInMetadataService(MetadataService::getSubscribedURLs);
}
@Override
- public List getExportedURLs(String serviceInterface, String group, String version, String protocol) {
+ public SortedSet getExportedURLs(String serviceInterface, String group, String version, String protocol) {
return doInMetadataService(metadataService ->
metadataService.getExportedURLs(serviceInterface, group, version, protocol));
}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLBuilder.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLBuilder.java
index 896cd4845f..f96f725fd2 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLBuilder.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLBuilder.java
@@ -17,65 +17,37 @@
package org.apache.dubbo.registry.client.metadata;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.metadata.MetadataService;
import org.apache.dubbo.registry.client.ServiceInstance;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-
-import static java.lang.String.valueOf;
-import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getMetadataServiceURLsParams;
-import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getProviderHost;
-import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getProviderPort;
+import java.util.ServiceLoader;
/**
- * The {@link URL} builder for {@link MetadataService}
+ * The builder interface of {@link MetadataService} to build {@link URL URLs}, the multiple implementations
+ * will be loaded by Java standard {@link ServiceLoader} and {@link #composite() composited},
+ * whose building {@link URL URLs} will be aggregated
*
- * @see MetadataService
+ * @see CompositeMetadataServiceURLBuilder
* @since 2.7.4
*/
-class MetadataServiceURLBuilder {
+public interface MetadataServiceURLBuilder {
/**
- * The singleton instance of {@link MetadataServiceURLBuilder}
- */
- public static final MetadataServiceURLBuilder INSTANCE = new MetadataServiceURLBuilder();
-
- private MetadataServiceURLBuilder() {
- }
-
- /**
- * Build the {@link URL urls} from {@link ServiceInstance#getMetadata() the metadata} of {@link ServiceInstance}
+ * Build the {@link URL URLs} from the specified {@link ServiceInstance}
*
* @param serviceInstance {@link ServiceInstance}
- * @return the not-null {@link List}
+ * @return non-null
*/
- public List build(ServiceInstance serviceInstance) {
+ List build(ServiceInstance serviceInstance);
- Map> paramsMap = getMetadataServiceURLsParams(serviceInstance);
-
- List urls = new ArrayList<>(paramsMap.size());
-
- for (Map.Entry> entry : paramsMap.entrySet()) {
-
- URLBuilder urlBuilder = new URLBuilder();
- String protocol = entry.getKey();
- Map urlParams = entry.getValue();
- String host = getProviderHost(urlParams);
- Integer port = getProviderPort(urlParams);
- urlBuilder.setHost(host)
- .setPort(port)
- .setProtocol(protocol)
- .setPath(MetadataService.class.getName());
-
- // add parameters
- entry.getValue().forEach((name, value) -> urlBuilder.addParameter(name, valueOf(value)));
-
- urls.add(urlBuilder.build());
- }
-
- return urls;
+ /**
+ * Get the composite implementation of {@link MetadataServiceURLBuilder}
+ *
+ * @return the instance of {@link CompositeMetadataServiceURLBuilder}
+ * @see CompositeMetadataServiceURLBuilder
+ */
+ static MetadataServiceURLBuilder composite() {
+ return new CompositeMetadataServiceURLBuilder();
}
}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLParamsMetadataCustomizer.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLParamsMetadataCustomizer.java
index 754a275168..fadc9c46a8 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLParamsMetadataCustomizer.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLParamsMetadataCustomizer.java
@@ -22,7 +22,7 @@ import org.apache.dubbo.metadata.WritableMetadataService;
import org.apache.dubbo.registry.client.ServiceInstance;
import org.apache.dubbo.registry.client.ServiceInstanceMetadataCustomizer;
-import java.util.List;
+import java.util.SortedSet;
import static org.apache.dubbo.metadata.MetadataService.toURLs;
import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.METADATA_SERVICE_URL_PARAMS_KEY;
@@ -53,7 +53,7 @@ public class MetadataServiceURLParamsMetadataCustomizer extends ServiceInstanceM
String version = MetadataService.VERSION;
- List urls = writableMetadataService.getExportedURLs(serviceInterface, group, version);
+ SortedSet urls = writableMetadataService.getExportedURLs(serviceInterface, group, version);
return getMetadataServiceParameter(toURLs(urls));
}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java
index 5a9dd6a4a6..dcebcec42d 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java
@@ -42,10 +42,22 @@ import static org.apache.dubbo.registry.integration.RegistryProtocol.DEFAULT_REG
*/
public class ServiceInstanceMetadataUtils {
+ /**
+ * The prefix of {@link MetadataService} : "dubbo.metadata-service."
+ */
+ public static final String DUBBO_METADATA_SERVICE_PREFIX = "dubbo.metadata-service.";
+
/**
* The key of metadata JSON of {@link MetadataService}'s {@link URL}
*/
- public static String METADATA_SERVICE_URL_PARAMS_KEY = "dubbo.metadata-service.url-params";
+ public static String METADATA_SERVICE_URL_PARAMS_KEY = DUBBO_METADATA_SERVICE_PREFIX + "url-params";
+
+ /**
+ * The {@link URL URLs} property name of {@link MetadataService} :
+ * "dubbo.metadata-service.urls", which is used to be compatible with Dubbo Spring Cloud and
+ * discovery the metadata of instance
+ */
+ public static final String DUBBO_METADATA_SERVICE_URLS_PROPERTY_NAME = DUBBO_METADATA_SERVICE_PREFIX + "urls";
/**
* The key of The revision for all exported Dubbo services.
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SpringCloudMetadataServiceURLBuilder.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SpringCloudMetadataServiceURLBuilder.java
new file mode 100644
index 0000000000..7eb3664d1c
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SpringCloudMetadataServiceURLBuilder.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.registry.client.metadata;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.utils.StringUtils;
+import org.apache.dubbo.registry.client.ServiceInstance;
+
+import com.alibaba.fastjson.JSON;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.DUBBO_METADATA_SERVICE_URLS_PROPERTY_NAME;
+
+/**
+ * The {@link MetadataServiceURLBuilder} implementation for The standard Dubbo scenario
+ *
+ * @since 2.7.4
+ */
+public class SpringCloudMetadataServiceURLBuilder implements MetadataServiceURLBuilder {
+
+ @Override
+ public List build(ServiceInstance serviceInstance) {
+ Map metadata = serviceInstance.getMetadata();
+ String dubboURLsJSON = metadata.get(DUBBO_METADATA_SERVICE_URLS_PROPERTY_NAME);
+ if (StringUtils.isBlank(dubboURLsJSON)) {
+ return Collections.emptyList();
+ }
+ List urlStrings = JSON.parseArray(dubboURLsJSON, String.class);
+ return urlStrings.stream().map(URL::valueOf).collect(Collectors.toList());
+ }
+}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/StandardMetadataServiceURLBuilder.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/StandardMetadataServiceURLBuilder.java
new file mode 100644
index 0000000000..48022af20a
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/StandardMetadataServiceURLBuilder.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.registry.client.metadata;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.URLBuilder;
+import org.apache.dubbo.metadata.MetadataService;
+import org.apache.dubbo.registry.client.ServiceInstance;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import static java.lang.String.valueOf;
+import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getMetadataServiceURLsParams;
+import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getProviderHost;
+import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getProviderPort;
+
+/**
+ * The {@link MetadataServiceURLBuilder} implementation for The standard Dubbo scenario
+ *
+ * @see MetadataService
+ * @since 2.7.4
+ */
+public class StandardMetadataServiceURLBuilder implements MetadataServiceURLBuilder {
+
+ /**
+ * Build the {@link URL urls} from {@link ServiceInstance#getMetadata() the metadata} of {@link ServiceInstance}
+ *
+ * @param serviceInstance {@link ServiceInstance}
+ * @return the not-null {@link List}
+ */
+ @Override
+ public List build(ServiceInstance serviceInstance) {
+
+ Map> paramsMap = getMetadataServiceURLsParams(serviceInstance);
+
+ List urls = new ArrayList<>(paramsMap.size());
+
+ for (Map.Entry> entry : paramsMap.entrySet()) {
+
+ URLBuilder urlBuilder = new URLBuilder();
+ String protocol = entry.getKey();
+ Map urlParams = entry.getValue();
+ String host = getProviderHost(urlParams);
+ Integer port = getProviderPort(urlParams);
+ urlBuilder.setHost(host)
+ .setPort(port)
+ .setProtocol(protocol)
+ .setPath(MetadataService.class.getName());
+
+ // add parameters
+ entry.getValue().forEach((name, value) -> urlBuilder.addParameter(name, valueOf(value)));
+
+ urls.add(urlBuilder.build());
+ }
+
+ return urls;
+ }
+}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/DefaultMetadataServiceProxyFactory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/DefaultMetadataServiceProxyFactory.java
index 2e5840b7ec..06248f9700 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/DefaultMetadataServiceProxyFactory.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/DefaultMetadataServiceProxyFactory.java
@@ -27,20 +27,21 @@ import org.apache.dubbo.rpc.cluster.Cluster;
import org.apache.dubbo.rpc.cluster.directory.StaticDirectory;
import org.apache.dubbo.rpc.cluster.support.AvailableCluster;
-import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import static org.apache.dubbo.registry.client.metadata.MetadataServiceURLBuilder.composite;
+
/**
- * The factory of {@link MetadataService}'s {@link Proxy}
+ * The default {@link MetadataServiceProxyFactory} to get the proxy of {@link MetadataService}
*
* @since 2.7.4
*/
public class DefaultMetadataServiceProxyFactory implements MetadataServiceProxyFactory {
- private final Map proxys = new HashMap<>();
+ private final Map proxies = new HashMap<>();
private ProxyFactory proxyFactory;
@@ -58,11 +59,11 @@ public class DefaultMetadataServiceProxyFactory implements MetadataServiceProxyF
@Override
public MetadataService getProxy(ServiceInstance serviceInstance) {
- return proxys.computeIfAbsent(serviceInstance.getId(), id -> createProxy(serviceInstance));
+ return proxies.computeIfAbsent(serviceInstance.getId(), id -> createProxy(serviceInstance));
}
protected MetadataService createProxy(ServiceInstance serviceInstance) {
- List urls = ServiceInstance.toUrls(serviceInstance);
+ List urls = composite().build(serviceInstance);
List> invokers = urls.stream()
.map(url -> protocol.refer(MetadataService.class, url))
.collect(Collectors.toList());
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/MetadataServiceProxyFactory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/MetadataServiceProxyFactory.java
index ffc097244c..fd55bb776f 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/MetadataServiceProxyFactory.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/MetadataServiceProxyFactory.java
@@ -29,7 +29,7 @@ import static org.apache.dubbo.common.extension.ExtensionLoader.getExtensionLoad
* @see MetadataService
* @since 2.7.4
*/
-@SPI("local")
+@SPI("default")
public interface MetadataServiceProxyFactory {
/**
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/ServiceOrientedRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/ServiceOrientedRegistry.java
index 8018effc71..9d388c8759 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/ServiceOrientedRegistry.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/ServiceOrientedRegistry.java
@@ -40,6 +40,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.SortedSet;
import java.util.stream.Collectors;
import static java.lang.String.format;
@@ -139,10 +140,15 @@ public class ServiceOrientedRegistry extends FailbackRegistry {
}
@Override
- public void doRegister(URL url) {
+ public final void register(URL url) {
if (!shouldRegister(url)) { // Should Not Register
return;
}
+ super.register(url);
+ }
+
+ @Override
+ public void doRegister(URL url) {
if (writableMetadataService.exportURL(url)) {
if (logger.isInfoEnabled()) {
logger.info(format("The URL[%s] registered successfully.", url.toString()));
@@ -155,10 +161,15 @@ public class ServiceOrientedRegistry extends FailbackRegistry {
}
@Override
- public void doUnregister(URL url) {
+ public final void unregister(URL url) {
if (!shouldRegister(url)) {
return;
}
+ super.unregister(url);
+ }
+
+ @Override
+ public void doUnregister(URL url) {
if (writableMetadataService.unexportURL(url)) {
if (logger.isInfoEnabled()) {
logger.info(format("The URL[%s] deregistered successfully.", url.toString()));
@@ -171,13 +182,26 @@ public class ServiceOrientedRegistry extends FailbackRegistry {
}
@Override
- public void doSubscribe(URL url, NotifyListener listener) {
+ public final void subscribe(URL url, NotifyListener listener) {
if (!shouldSubscribe(url)) { // Should Not Subscribe
return;
}
+ super.subscribe(url, listener);
+ }
+
+ @Override
+ public void doSubscribe(URL url, NotifyListener listener) {
subscribeURLs(url, listener);
}
+ @Override
+ public final void unsubscribe(URL url, NotifyListener listener) {
+ if (!shouldSubscribe(url)) { // Should Not Subscribe
+ return;
+ }
+ super.unsubscribe(url, listener);
+ }
+
@Override
public void doUnsubscribe(URL url, NotifyListener listener) {
writableMetadataService.unsubscribeURL(url);
@@ -401,7 +425,7 @@ public class ServiceOrientedRegistry extends FailbackRegistry {
try {
MetadataService metadataService = metadataServiceProxyFactory.getProxy(providerInstance);
- List urls = metadataService.getExportedURLs(serviceInterface, group, version, protocol);
+ SortedSet urls = metadataService.getExportedURLs(serviceInterface, group, version, protocol);
exportedURLs = urls.stream().map(URL::valueOf).collect(Collectors.toList());
} catch (Throwable e) {
if (logger.isErrorEnabled()) {
diff --git a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.MetadataServiceProxyFactory b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.MetadataServiceProxyFactory
deleted file mode 100644
index 4886058702..0000000000
--- a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.MetadataServiceProxyFactory
+++ /dev/null
@@ -1 +0,0 @@
-default=org.apache.dubbo.registry.client.metadata.DefaultMetadataServiceProxyFactory
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.proxy.MetadataServiceProxyFactory b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.proxy.MetadataServiceProxyFactory
index d9283dec44..359dbe8b9b 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.proxy.MetadataServiceProxyFactory
+++ b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.proxy.MetadataServiceProxyFactory
@@ -1,2 +1,2 @@
-local=org.apache.dubbo.registry.client.metadata.proxy.DefaultMetadataServiceProxyFactory
+default=org.apache.dubbo.registry.client.metadata.proxy.DefaultMetadataServiceProxyFactory
remote=org.apache.dubbo.registry.client.metadata.proxy.RemoteMetadataServiceProxyFactory
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/services/org.apache.dubbo.registry.client.metadata.MetadataServiceURLBuilder b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/services/org.apache.dubbo.registry.client.metadata.MetadataServiceURLBuilder
new file mode 100644
index 0000000000..418ebb7d92
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/services/org.apache.dubbo.registry.client.metadata.MetadataServiceURLBuilder
@@ -0,0 +1,2 @@
+org.apache.dubbo.registry.client.metadata.StandardMetadataServiceURLBuilder
+org.apache.dubbo.registry.client.metadata.SpringCloudMetadataServiceURLBuilder
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/DefaultServiceInstanceTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/DefaultServiceInstanceTest.java
index 38739f18b9..c48bfa9758 100644
--- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/DefaultServiceInstanceTest.java
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/DefaultServiceInstanceTest.java
@@ -30,31 +30,37 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*/
public class DefaultServiceInstanceTest {
- public static DefaultServiceInstance INSTANCE =
- new DefaultServiceInstance("A", "127.0.0.1", 8080);
+ public DefaultServiceInstance instance;
+
+ public static DefaultServiceInstance createInstance() {
+ DefaultServiceInstance instance = new DefaultServiceInstance("A", "127.0.0.1", 8080);
+ instance.getMetadata().put("dubbo.metadata-service.urls", "[ \"dubbo://192.168.0.102:20881/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=spring-cloud-alibaba-dubbo-provider&bind.ip=192.168.0.102&bind.port=20881&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=spring-cloud-alibaba-dubbo-provider&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=17134&qos.enable=false®ister=true&release=2.7.3&revision=1.0.0&side=provider×tamp=1564826098503&version=1.0.0\" ]");
+ instance.getMetadata().put("dubbo.metadata-service.url-params", "{\"dubbo\":{\"application\":\"dubbo-provider-demo\",\"deprecated\":\"false\",\"group\":\"dubbo-provider-demo\",\"version\":\"1.0.0\",\"timestamp\":\"1564845042651\",\"dubbo\":\"2.0.2\",\"provider.host\":\"192.168.0.102\",\"provider.port\":\"20880\"}}");
+ return instance;
+ }
@BeforeEach
public void init() {
- INSTANCE = new DefaultServiceInstance("A", "127.0.0.1", 8080);
+ instance = createInstance();
}
@Test
public void testDefaultValues() {
- assertTrue(INSTANCE.isEnabled());
- assertTrue(INSTANCE.isHealthy());
- assertTrue(INSTANCE.getMetadata().isEmpty());
+ assertTrue(instance.isEnabled());
+ assertTrue(instance.isHealthy());
+ assertFalse(instance.getMetadata().isEmpty());
}
@Test
public void testSetAndGetValues() {
- INSTANCE.setEnabled(false);
- INSTANCE.setHealthy(false);
+ instance.setEnabled(false);
+ instance.setHealthy(false);
- assertEquals("A", INSTANCE.getServiceName());
- assertEquals("127.0.0.1", INSTANCE.getHost());
- assertEquals(8080, INSTANCE.getPort());
- assertFalse(INSTANCE.isEnabled());
- assertFalse(INSTANCE.isHealthy());
- assertTrue(INSTANCE.getMetadata().isEmpty());
+ assertEquals("A", instance.getServiceName());
+ assertEquals("127.0.0.1", instance.getHost());
+ assertEquals(8080, instance.getPort());
+ assertFalse(instance.isEnabled());
+ assertFalse(instance.isHealthy());
+ assertFalse(instance.getMetadata().isEmpty());
}
}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/context/annotation/provider/DefaultHelloService.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java
similarity index 53%
rename from dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/context/annotation/provider/DefaultHelloService.java
rename to dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java
index 8277bc9b4e..0b022b0c1b 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/context/annotation/provider/DefaultHelloService.java
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java
@@ -14,27 +14,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.config.spring.context.context.annotation.provider;
+package org.apache.dubbo.registry.client.event.listener;
-import org.apache.dubbo.config.spring.annotation.merged.MergedService;
-import org.apache.dubbo.config.spring.api.HelloService;
+import org.apache.dubbo.registry.client.DefaultServiceInstanceTest;
+import org.apache.dubbo.registry.client.event.ServiceInstancePreRegisteredEvent;
-import org.springframework.stereotype.Service;
+import org.junit.jupiter.api.Test;
/**
- * Default {@link HelloService} annotation with Spring's {@link Service}
- * and Dubbo's {@link org.apache.dubbo.config.annotation.Service}
+ * {@link CustomizableServiceInstanceListener} Test
*
- * @since TODO
+ * @since 2.7.4
*/
-@Service
-//@org.apache.dubbo.config.annotation.Service
-@MergedService
-public class DefaultHelloService implements HelloService {
+public class CustomizableServiceInstanceListenerTest {
- @Override
- public String sayHello(String name) {
- return "Greeting, " + name;
+ private CustomizableServiceInstanceListener listener = new CustomizableServiceInstanceListener();
+
+ @Test
+ public void testOnEvent() {
+ ServiceInstancePreRegisteredEvent event = new ServiceInstancePreRegisteredEvent(this, DefaultServiceInstanceTest.createInstance());
+ // breaking test
+ listener.onEvent(event);
}
-
}
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/LoggingEventListenerTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/LoggingEventListenerTest.java
new file mode 100644
index 0000000000..ddd3aecd08
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/LoggingEventListenerTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.registry.client.event.listener;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.registry.client.FileSystemServiceDiscovery;
+import org.apache.dubbo.registry.client.ServiceDiscovery;
+import org.apache.dubbo.registry.client.event.ServiceDiscoveryStartedEvent;
+import org.apache.dubbo.registry.client.event.ServiceDiscoveryStartingEvent;
+import org.apache.dubbo.registry.client.event.ServiceDiscoveryStoppedEvent;
+import org.apache.dubbo.registry.client.event.ServiceDiscoveryStoppingEvent;
+import org.apache.dubbo.registry.client.event.ServiceInstancePreRegisteredEvent;
+import org.apache.dubbo.registry.client.event.ServiceInstancePreUnregisteredEvent;
+import org.apache.dubbo.registry.client.event.ServiceInstanceRegisteredEvent;
+import org.apache.dubbo.registry.client.event.ServiceInstanceUnregisteredEvent;
+import org.apache.dubbo.registry.client.event.ServiceInstancesChangedEvent;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static java.util.Collections.singleton;
+import static org.apache.dubbo.registry.client.DefaultServiceInstanceTest.createInstance;
+
+/**
+ * {@link LoggingEventListener} Test
+ *
+ * @since 2.7.4
+ */
+public class LoggingEventListenerTest {
+
+ private LoggingEventListener listener;
+
+ @BeforeEach
+ public void init() {
+ listener = new LoggingEventListener();
+ }
+
+ @Test
+ public void testOnEvent() {
+
+ URL connectionURL = URL.valueOf("file:///Users/Home");
+ ServiceDiscovery serviceDiscovery = new FileSystemServiceDiscovery(connectionURL);
+
+ // ServiceDiscoveryStartingEvent
+ listener.onEvent(new ServiceDiscoveryStartingEvent(serviceDiscovery));
+
+ // ServiceDiscoveryStartedEvent
+ listener.onEvent(new ServiceDiscoveryStartedEvent(serviceDiscovery));
+
+ // ServiceInstancePreRegisteredEvent
+ listener.onEvent(new ServiceInstancePreRegisteredEvent(serviceDiscovery, createInstance()));
+
+ // ServiceInstanceRegisteredEvent
+ listener.onEvent(new ServiceInstanceRegisteredEvent(serviceDiscovery, createInstance()));
+
+ // ServiceInstancesChangedEvent
+ listener.onEvent(new ServiceInstancesChangedEvent("test", singleton(createInstance())));
+
+ // ServiceInstancePreUnregisteredEvent
+ listener.onEvent(new ServiceInstancePreUnregisteredEvent(serviceDiscovery, createInstance()));
+
+ // ServiceInstanceUnregisteredEvent
+ listener.onEvent(new ServiceInstanceUnregisteredEvent(serviceDiscovery, createInstance()));
+
+ // ServiceDiscoveryStoppingEvent
+ listener.onEvent(new ServiceDiscoveryStoppingEvent(serviceDiscovery));
+
+ // ServiceDiscoveryStoppedEvent
+ listener.onEvent(new ServiceDiscoveryStoppedEvent(serviceDiscovery));
+ }
+}
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListenerTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListenerTest.java
new file mode 100644
index 0000000000..898e732405
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListenerTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.registry.client.event.listener;
+
+import org.apache.dubbo.event.Event;
+import org.apache.dubbo.event.EventDispatcher;
+import org.apache.dubbo.registry.client.event.ServiceInstancesChangedEvent;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import static java.util.Collections.emptyList;
+import static org.apache.dubbo.event.EventDispatcher.getDefaultExtension;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * {@link ServiceInstancesChangedListener} Test
+ *
+ * @since 2.7.4
+ */
+public class ServiceInstancesChangedListenerTest {
+
+ @Test
+ public void testOnEvent() {
+
+ EventDispatcher eventDispatcher = getDefaultExtension();
+
+ Event event = new ServiceInstancesChangedEvent("test", emptyList());
+
+ AtomicReference eventRef = new AtomicReference<>();
+
+ eventDispatcher.addEventListener((ServiceInstancesChangedListener) eventRef::set);
+
+ // Dispatch a ServiceInstancesChangedEvent
+ eventDispatcher.dispatch(event);
+
+ assertEquals(eventRef.get(), event);
+ }
+}
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLBuilderTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLBuilderTest.java
new file mode 100644
index 0000000000..5c905779d2
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLBuilderTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.registry.client.metadata;
+
+import org.apache.dubbo.registry.client.DefaultServiceInstance;
+import org.apache.dubbo.registry.client.ServiceInstance;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.dubbo.registry.client.metadata.MetadataServiceURLBuilder.composite;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * {@link MetadataServiceURLBuilder} Test
+ *
+ * @since 2.7.4
+ */
+public class MetadataServiceURLBuilderTest {
+
+ static ServiceInstance serviceInstance = new DefaultServiceInstance("127.0.0.1", "test", 8080);
+
+ static {
+ serviceInstance.getMetadata().put("dubbo.metadata-service.urls", "[ \"dubbo://192.168.0.102:20881/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=spring-cloud-alibaba-dubbo-provider&bind.ip=192.168.0.102&bind.port=20881&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=spring-cloud-alibaba-dubbo-provider&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=17134&qos.enable=false®ister=true&release=2.7.3&revision=1.0.0&side=provider×tamp=1564826098503&version=1.0.0\" ]");
+ serviceInstance.getMetadata().put("dubbo.metadata-service.url-params", "{\"dubbo\":{\"application\":\"dubbo-provider-demo\",\"deprecated\":\"false\",\"group\":\"dubbo-provider-demo\",\"version\":\"1.0.0\",\"timestamp\":\"1564845042651\",\"dubbo\":\"2.0.2\",\"provider.host\":\"192.168.0.102\",\"provider.port\":\"20880\"}}");
+ }
+
+ @Test
+ public void testComposite() {
+ assertEquals(CompositeMetadataServiceURLBuilder.class, composite().getClass());
+ }
+
+ @Test
+ public void testBuild() {
+ assertTrue(composite().build(null).isEmpty());
+ assertTrue(composite().build(new DefaultServiceInstance("127.0.0.1", "test", 8080)).isEmpty());
+ assertEquals(2, composite().build(serviceInstance).size());
+ }
+}
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtilsTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtilsTest.java
index 1fc056653e..6f88b8a813 100644
--- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtilsTest.java
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtilsTest.java
@@ -18,10 +18,13 @@ package org.apache.dubbo.registry.client.metadata;
import org.apache.dubbo.common.URL;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -35,7 +38,7 @@ public class ServiceInstanceMetadataUtilsTest {
private static URL url = URL.valueOf("dubbo://192.168.0.102:20880/org.apache.dubbo.metadata.MetadataService?&anyhost=true&application=spring-cloud-alibaba-dubbo-provider&bind.ip=192.168.0.102&bind.port=20880&default.deprecated=false&default.dynamic=false&default.register=true&deprecated=false&dubbo=2.0.2&dynamic=false&generic=false&group=spring-cloud-alibaba-dubbo-provider&interface=org.apache.dubbo.metadata.MetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=58350®ister=true&release=2.7.1&revision=1.0.0&side=provider×tamp=1557928573174&version=1.0.0");
private static URL url2 = URL.valueOf("rest://192.168.0.102:20880/org.apache.dubbo.metadata.MetadataService?&anyhost=true&application=spring-cloud-alibaba-dubbo-provider&bind.ip=192.168.0.102&bind.port=20880&default.deprecated=false&default.dynamic=false&default.register=true&deprecated=false&dubbo=2.0.2&dynamic=false&generic=false&group=spring-cloud-alibaba-dubbo-provider&interface=org.apache.dubbo.metadata.MetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=58350®ister=true&release=2.7.1&revision=1.0.0&side=provider×tamp=1557928573174&version=1.0.0");
- private static final String VALUE = "{\"rest\":{\"application\":\"spring-cloud-alibaba-dubbo-provider\",\"bind.ip\":\"192.168.0.102\",\"bind.port\":\"20880\",\"dubbo\":\"2.0.2\",\"release\":\"2.7.1\",\"side\":\"provider\",\"version\":\"1.0.0\"},\"dubbo\":{\"application\":\"spring-cloud-alibaba-dubbo-provider\",\"bind.ip\":\"192.168.0.102\",\"bind.port\":\"20880\",\"dubbo\":\"2.0.2\",\"release\":\"2.7.1\",\"side\":\"provider\",\"version\":\"1.0.0\"}}";
+ private static final String VALUE = "{\"rest\":{\"application\":\"spring-cloud-alibaba-dubbo-provider\",\"deprecated\":\"false\",\"group\":\"spring-cloud-alibaba-dubbo-provider\",\"version\":\"1.0.0\",\"timestamp\":\"1557928573174\",\"dubbo\":\"2.0.2\",\"release\":\"2.7.1\",\"provider.host\":\"192.168.0.102\",\"provider.port\":\"20880\"},\"dubbo\":{\"application\":\"spring-cloud-alibaba-dubbo-provider\",\"deprecated\":\"false\",\"group\":\"spring-cloud-alibaba-dubbo-provider\",\"version\":\"1.0.0\",\"timestamp\":\"1557928573174\",\"dubbo\":\"2.0.2\",\"release\":\"2.7.1\",\"provider.host\":\"192.168.0.102\",\"provider.port\":\"20880\"}}";
@Test
public void testMetadataServiceURLParameters() {
@@ -44,6 +47,18 @@ public class ServiceInstanceMetadataUtilsTest {
String parameter = ServiceInstanceMetadataUtils.getMetadataServiceParameter(urls);
+ JSONObject jsonObject = JSON.parseObject(parameter);
+
+ urls.forEach(url -> {
+ JSONObject map = jsonObject.getJSONObject(url.getProtocol());
+ for (Map.Entry param : url.getParameters().entrySet()) {
+ String value = map.getString(param.getKey());
+ if (value != null) {
+ assertEquals(param.getValue(), value);
+ }
+ }
+ });
+
assertEquals(VALUE, parameter);
}
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/SpringCloudMetadataServiceURLBuilderTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/SpringCloudMetadataServiceURLBuilderTest.java
new file mode 100644
index 0000000000..0a2b9f4a46
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/metadata/SpringCloudMetadataServiceURLBuilderTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.registry.client.metadata;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.registry.client.DefaultServiceInstance;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.apache.dubbo.registry.client.metadata.MetadataServiceURLBuilderTest.serviceInstance;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * {@link SpringCloudMetadataServiceURLBuilder} Test
+ *
+ * @since 2.7.4
+ */
+public class SpringCloudMetadataServiceURLBuilderTest {
+
+ private SpringCloudMetadataServiceURLBuilder builder = new SpringCloudMetadataServiceURLBuilder();
+
+ @Test
+ public void testBuild() {
+ List urls = builder.build(new DefaultServiceInstance("127.0.0.1", "test", 8080));
+ assertEquals(0, urls.size());
+
+ urls = builder.build(serviceInstance);
+ assertEquals(1, urls.size());
+ URL url = urls.get(0);
+ assertEquals("192.168.0.102", url.getHost());
+ assertEquals(20881, url.getPort());
+ assertEquals("com.alibaba.cloud.dubbo.service.DubboMetadataService", url.getServiceInterface());
+ }
+
+}
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/ServiceOrientedRegistryTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/ServiceOrientedRegistryTest.java
index 9840a255f8..ec40682284 100644
--- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/ServiceOrientedRegistryTest.java
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/ServiceOrientedRegistryTest.java
@@ -25,8 +25,11 @@ import org.junit.jupiter.api.Test;
import java.util.LinkedList;
import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
-import static java.util.Collections.emptyList;
+import static java.util.Arrays.asList;
+import static java.util.Collections.unmodifiableSortedSet;
import static org.apache.dubbo.common.URL.valueOf;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_PROTOCOL;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
@@ -51,7 +54,7 @@ public class ServiceOrientedRegistryTest {
private static final String SERVICE_INTERFACE = "org.apache.dubbo.metadata.MetadataService";
- private static final String GROUP = "spring-cloud-alibaba-dubbo-provider";
+ private static final String GROUP = "dubbo-provider";
private static final String VERSION = "1.0.0";
@@ -94,11 +97,11 @@ public class ServiceOrientedRegistryTest {
registry.register(url);
- List urls = metadataService.getExportedURLs();
+ SortedSet urls = metadataService.getExportedURLs();
- assertEquals(emptyList(), urls);
- assertEquals(metadataService.getExportedURLs(SERVICE_INTERFACE), urls);
- assertEquals(metadataService.getExportedURLs(SERVICE_INTERFACE, GROUP), urls);
+ assertTrue(urls.isEmpty());
+ assertEquals(toSortedSet(), metadataService.getExportedURLs(SERVICE_INTERFACE));
+ assertEquals(toSortedSet(), metadataService.getExportedURLs(SERVICE_INTERFACE, GROUP));
assertEquals(metadataService.getExportedURLs(SERVICE_INTERFACE, GROUP, VERSION), urls);
assertEquals(metadataService.getExportedURLs(SERVICE_INTERFACE, GROUP, VERSION, DEFAULT_PROTOCOL), urls);
@@ -110,8 +113,8 @@ public class ServiceOrientedRegistryTest {
urls = metadataService.getExportedURLs();
- assertEquals(metadataService.getExportedURLs(serviceInterface, GROUP, VERSION), urls);
- assertEquals(metadataService.getExportedURLs(serviceInterface, GROUP, VERSION, DEFAULT_PROTOCOL), urls);
+ assertEquals(metadataService.getExportedURLs(serviceInterface, GROUP, VERSION), toSortedSet(urls.first()));
+ assertEquals(metadataService.getExportedURLs(serviceInterface, GROUP, VERSION, DEFAULT_PROTOCOL), toSortedSet(urls.first()));
}
@@ -125,7 +128,7 @@ public class ServiceOrientedRegistryTest {
// register
registry.register(newURL);
- List urls = metadataService.getExportedURLs();
+ SortedSet urls = metadataService.getExportedURLs();
assertFalse(urls.isEmpty());
assertEquals(metadataService.getExportedURLs(serviceInterface, GROUP, VERSION), urls);
@@ -136,7 +139,7 @@ public class ServiceOrientedRegistryTest {
urls = metadataService.getExportedURLs();
- assertEquals(emptyList(), urls);
+ assertEquals(toSortedSet(), urls);
assertEquals(metadataService.getExportedURLs(SERVICE_INTERFACE), urls);
assertEquals(metadataService.getExportedURLs(SERVICE_INTERFACE, GROUP), urls);
assertEquals(metadataService.getExportedURLs(SERVICE_INTERFACE, GROUP, VERSION), urls);
@@ -148,10 +151,9 @@ public class ServiceOrientedRegistryTest {
registry.subscribe(url, new MyNotifyListener());
- List urls = metadataService.getSubscribedURLs();
+ SortedSet urls = metadataService.getSubscribedURLs();
- assertFalse(urls.isEmpty());
- assertEquals(url, urls.get(0));
+ assertTrue(urls.isEmpty());
}
@@ -170,4 +172,8 @@ public class ServiceOrientedRegistryTest {
}
}
+ private static > SortedSet toSortedSet(T... values) {
+ return unmodifiableSortedSet(new TreeSet<>(asList(values)));
+ }
+
}
diff --git a/dubbo-registry/dubbo-registry-consul/pom.xml b/dubbo-registry/dubbo-registry-consul/pom.xml
index 0b40fbf0b0..c2844abbdb 100644
--- a/dubbo-registry/dubbo-registry-consul/pom.xml
+++ b/dubbo-registry/dubbo-registry-consul/pom.xml
@@ -21,6 +21,7 @@
dubbo-registry
org.apache.dubbo
${revision}
+ ../pom.xml
4.0.0
diff --git a/dubbo-registry/dubbo-registry-default/pom.xml b/dubbo-registry/dubbo-registry-default/pom.xml
index 37df8f2ef7..b2eeecb1cb 100644
--- a/dubbo-registry/dubbo-registry-default/pom.xml
+++ b/dubbo-registry/dubbo-registry-default/pom.xml
@@ -21,6 +21,7 @@
org.apache.dubbo
dubbo-registry
${revision}
+ ../pom.xml
dubbo-registry-default
jar
diff --git a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java
index 5e84ece034..192ed588fa 100644
--- a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java
+++ b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java
@@ -41,8 +41,8 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.apache.dubbo.rpc.cluster.Constants.EXPORT_KEY;
import static org.apache.dubbo.registry.integration.RegistryProtocol.DEFAULT_REGISTER_PROVIDER_KEYS;
+import static org.apache.dubbo.rpc.cluster.Constants.EXPORT_KEY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
diff --git a/dubbo-registry/dubbo-registry-etcd3/pom.xml b/dubbo-registry/dubbo-registry-etcd3/pom.xml
index 6d9d60cbd5..4464685274 100644
--- a/dubbo-registry/dubbo-registry-etcd3/pom.xml
+++ b/dubbo-registry/dubbo-registry-etcd3/pom.xml
@@ -22,6 +22,7 @@
dubbo-registry
org.apache.dubbo
${revision}
+ ../pom.xml
dubbo-registry-etcd3
diff --git a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
index 4cce645ef1..f10a0b0dd5 100644
--- a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
+++ b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java
@@ -38,8 +38,6 @@ import com.google.gson.Gson;
import java.io.File;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -47,8 +45,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY;
-
/**
* 2019-07-08
*/
diff --git a/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java b/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java
index f09ff804d1..079aadd789 100644
--- a/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java
+++ b/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java
@@ -79,12 +79,12 @@ import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
-import static org.apache.dubbo.registry.Constants.ADMIN_PROTOCOL;
import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY;
import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDERS_CATEGORY;
import static org.apache.dubbo.common.constants.RegistryConstants.ROUTERS_CATEGORY;
+import static org.apache.dubbo.registry.Constants.ADMIN_PROTOCOL;
@Disabled
public class EtcdRegistryTest {
diff --git a/dubbo-registry/dubbo-registry-multicast/pom.xml b/dubbo-registry/dubbo-registry-multicast/pom.xml
index 643159bddd..8e03ce51d4 100644
--- a/dubbo-registry/dubbo-registry-multicast/pom.xml
+++ b/dubbo-registry/dubbo-registry-multicast/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-registry
${revision}
+ ../pom.xml
dubbo-registry-multicast
jar
diff --git a/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java b/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java
index 0c2844552e..79e450fbdf 100644
--- a/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java
+++ b/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java
@@ -51,14 +51,14 @@ import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
-import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL;
-import static org.apache.dubbo.registry.Constants.DEFAULT_SESSION_TIMEOUT;
import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL;
import static org.apache.dubbo.common.constants.RegistryConstants.OVERRIDE_PROTOCOL;
+import static org.apache.dubbo.common.constants.RegistryConstants.ROUTE_PROTOCOL;
+import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL;
+import static org.apache.dubbo.registry.Constants.DEFAULT_SESSION_TIMEOUT;
import static org.apache.dubbo.registry.Constants.REGISTER;
import static org.apache.dubbo.registry.Constants.REGISTER_KEY;
-import static org.apache.dubbo.common.constants.RegistryConstants.ROUTE_PROTOCOL;
import static org.apache.dubbo.registry.Constants.SESSION_TIMEOUT_KEY;
import static org.apache.dubbo.registry.Constants.SUBSCRIBE;
import static org.apache.dubbo.registry.Constants.UNREGISTER;
diff --git a/dubbo-registry/dubbo-registry-multiple/pom.xml b/dubbo-registry/dubbo-registry-multiple/pom.xml
index e62e2fe21b..aa7c1a2602 100644
--- a/dubbo-registry/dubbo-registry-multiple/pom.xml
+++ b/dubbo-registry/dubbo-registry-multiple/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-registry
${revision}
+ ../pom.xml
dubbo-registry-multiple
jar
diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java
index 4c3bc5c01e..721da52c14 100644
--- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java
+++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java
@@ -21,9 +21,6 @@ import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.RegistryFactory;
import org.apache.dubbo.registry.support.AbstractRegistryFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import static org.apache.dubbo.registry.nacos.util.NacosNamingServiceUtils.createNamingService;
/**
diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java
index fd08d9ec85..98c9b5bbe1 100644
--- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java
+++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java
@@ -1,4 +1,4 @@
-package org.apache.dubbo.registry.nacos.util;/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -14,6 +14,7 @@ package org.apache.dubbo.registry.nacos.util;/*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.dubbo.registry.nacos.util;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
diff --git a/dubbo-registry/dubbo-registry-redis/pom.xml b/dubbo-registry/dubbo-registry-redis/pom.xml
index 8144089f35..e6e99b9d46 100644
--- a/dubbo-registry/dubbo-registry-redis/pom.xml
+++ b/dubbo-registry/dubbo-registry-redis/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-registry
${revision}
+ ../pom.xml
dubbo-registry-redis
jar
diff --git a/dubbo-registry/dubbo-registry-zookeeper/pom.xml b/dubbo-registry/dubbo-registry-zookeeper/pom.xml
index cf3a1a90e1..2d810dbfdf 100644
--- a/dubbo-registry/dubbo-registry-zookeeper/pom.xml
+++ b/dubbo-registry/dubbo-registry-zookeeper/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-registry
${revision}
+ ../pom.xml
dubbo-registry-zookeeper
jar
diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
index 4ddf1518e6..fbfc750bb9 100644
--- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
+++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
@@ -60,8 +60,6 @@ public class ZookeeperRegistry extends FailbackRegistry {
private final static Logger logger = LoggerFactory.getLogger(ZookeeperRegistry.class);
- private final static int DEFAULT_ZOOKEEPER_PORT = 2181;
-
private final static String DEFAULT_ROOT = "dubbo";
private final String root;
diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java
index 888972a82d..9ee5dde7cf 100644
--- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java
+++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java
@@ -21,6 +21,8 @@ import org.apache.dubbo.common.function.ThrowableConsumer;
import org.apache.dubbo.common.function.ThrowableFunction;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.DefaultPage;
+import org.apache.dubbo.common.utils.Page;
import org.apache.dubbo.event.EventDispatcher;
import org.apache.dubbo.event.EventListener;
import org.apache.dubbo.registry.client.ServiceDiscovery;
@@ -32,7 +34,9 @@ import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.api.CuratorWatcher;
import org.apache.zookeeper.KeeperException;
+import java.util.Iterator;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -113,6 +117,39 @@ public class ZookeeperServiceDiscovery implements ServiceDiscovery, EventListene
return doInServiceDiscovery(s -> build(s.queryForInstances(serviceName)));
}
+ @Override
+ public Page getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly) {
+ String path = buildServicePath(serviceName);
+
+ return execute(path, p -> {
+
+ List serviceInstances = new LinkedList<>();
+
+ List serviceIds = new LinkedList<>(curatorFramework.getChildren().forPath(p));
+
+ int totalSize = serviceIds.size();
+
+ Iterator iterator = serviceIds.iterator();
+
+ for (int i = 0; i < offset; i++) {
+ if (iterator.hasNext()) { // remove the elements from 0 to offset
+ iterator.next();
+ iterator.remove();
+ }
+ }
+
+ for (int i = 0; i < pageSize; i++) {
+ if (iterator.hasNext()) {
+ String serviceId = iterator.next();
+ ServiceInstance serviceInstance = build(serviceDiscovery.queryForInstance(serviceName, serviceId));
+ serviceInstances.add(serviceInstance);
+ }
+ }
+
+ return new DefaultPage<>(offset, pageSize, serviceInstances, totalSize);
+ });
+ }
+
@Override
public void addServiceInstancesChangedListener(String serviceName, ServiceInstancesChangedListener listener)
throws NullPointerException, IllegalArgumentException {
diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryTest.java b/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryTest.java
index 80819ec4eb..d0b10f690d 100644
--- a/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryTest.java
+++ b/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistryTest.java
@@ -55,8 +55,9 @@ public class ZookeeperRegistryTest {
public void setUp() throws Exception {
int zkServerPort = NetUtils.getAvailablePort();
this.zkServer = new TestingServer(zkServerPort, true);
- this.registryUrl = URL.valueOf("zookeeper://localhost:" + zkServerPort);
+ this.zkServer.start();
+ this.registryUrl = URL.valueOf("zookeeper://localhost:" + zkServerPort);
zookeeperRegistryFactory = new ZookeeperRegistryFactory();
zookeeperRegistryFactory.setZookeeperTransporter(new CuratorZookeeperTransporter());
this.zookeeperRegistry = (ZookeeperRegistry) zookeeperRegistryFactory.createRegistry(registryUrl);
diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscoveryTest.java b/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscoveryTest.java
index 61870224ca..5f14ec5849 100644
--- a/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscoveryTest.java
+++ b/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscoveryTest.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.registry.zookeeper;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.Page;
+import org.apache.dubbo.event.EventDispatcher;
import org.apache.dubbo.registry.client.DefaultServiceInstance;
import org.apache.dubbo.registry.client.ServiceInstance;
@@ -60,6 +61,7 @@ public class ZookeeperServiceDiscoveryTest {
@BeforeEach
public void init() throws Exception {
+ EventDispatcher.getDefaultExtension().removeAllEventListeners();
zkServerPort = getAvailablePort();
zkServer = new TestingServer(zkServerPort, true);
zkServer.start();
diff --git a/dubbo-registry/pom.xml b/dubbo-registry/pom.xml
index 32db5d495a..b32ad5e887 100644
--- a/dubbo-registry/pom.xml
+++ b/dubbo-registry/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-parent
${revision}
+ ../pom.xml
dubbo-registry
pom
diff --git a/dubbo-remoting/dubbo-remoting-api/pom.xml b/dubbo-remoting/dubbo-remoting-api/pom.xml
index 6d35681d9f..69ed09499b 100644
--- a/dubbo-remoting/dubbo-remoting-api/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-api/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-remoting
${revision}
+ ../pom.xml
dubbo-remoting-api
jar
diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientFixedTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientFixedTest.java
index 93ccc76e51..8380f5a675 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientFixedTest.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientFixedTest.java
@@ -80,7 +80,7 @@ public class PerformanceClientFixedTest {
} catch (Throwable t) {
t.printStackTrace();
} finally {
- if (client != null && client.isConnected() == false) {
+ if (client != null && !client.isConnected()) {
f++;
System.out.println("open client failed, try again " + f);
client.close();
diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/AbstractCodecTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/AbstractCodecTest.java
index 44ea23338a..ed07ebb2d8 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/AbstractCodecTest.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/AbstractCodecTest.java
@@ -16,13 +16,14 @@
*/
package org.apache.dubbo.remoting.transport;
-import java.io.IOException;
-
import org.apache.dubbo.common.URL;
import org.apache.dubbo.remoting.Channel;
+
import org.hamcrest.CoreMatchers;
import org.mockito.internal.verification.VerificationModeFactory;
+import java.io.IOException;
+
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.BDDMockito.given;
diff --git a/dubbo-remoting/dubbo-remoting-etcd3/pom.xml b/dubbo-remoting/dubbo-remoting-etcd3/pom.xml
index 73a2539bda..285854bda8 100644
--- a/dubbo-remoting/dubbo-remoting-etcd3/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-etcd3/pom.xml
@@ -24,6 +24,7 @@
dubbo-remoting
org.apache.dubbo
${revision}
+ ../pom.xml
dubbo-remoting-etcd3
jar
diff --git a/dubbo-remoting/dubbo-remoting-grizzly/pom.xml b/dubbo-remoting/dubbo-remoting-grizzly/pom.xml
index cd185367fd..1d5a7f1017 100644
--- a/dubbo-remoting/dubbo-remoting-grizzly/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-grizzly/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-remoting
${revision}
+ ../pom.xml
dubbo-remoting-grizzly
jar
diff --git a/dubbo-remoting/dubbo-remoting-http/pom.xml b/dubbo-remoting/dubbo-remoting-http/pom.xml
index 19c8220e40..4c3cc99d48 100644
--- a/dubbo-remoting/dubbo-remoting-http/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-http/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-remoting
${revision}
+ ../pom.xml
dubbo-remoting-http
jar
diff --git a/dubbo-remoting/dubbo-remoting-mina/pom.xml b/dubbo-remoting/dubbo-remoting-mina/pom.xml
index 4808a1781c..76725e6a12 100644
--- a/dubbo-remoting/dubbo-remoting-mina/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-mina/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-remoting
${revision}
+ ../pom.xml
dubbo-remoting-mina
jar
diff --git a/dubbo-remoting/dubbo-remoting-netty/pom.xml b/dubbo-remoting/dubbo-remoting-netty/pom.xml
index 761d37b516..d048f5be1b 100644
--- a/dubbo-remoting/dubbo-remoting-netty/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-netty/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-remoting
${revision}
+ ../pom.xml
dubbo-remoting-netty
jar
diff --git a/dubbo-remoting/dubbo-remoting-netty4/pom.xml b/dubbo-remoting/dubbo-remoting-netty4/pom.xml
index 10d7f26fe1..99dd144996 100644
--- a/dubbo-remoting/dubbo-remoting-netty4/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-netty4/pom.xml
@@ -19,6 +19,7 @@
dubbo-remoting
org.apache.dubbo
${revision}
+ ../pom.xml
4.0.0
diff --git a/dubbo-remoting/dubbo-remoting-p2p/pom.xml b/dubbo-remoting/dubbo-remoting-p2p/pom.xml
index f947606288..ff0bbee5e2 100644
--- a/dubbo-remoting/dubbo-remoting-p2p/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-p2p/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-remoting
${revision}
+ ../pom.xml
dubbo-remoting-p2p
jar
diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml b/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml
index bf4cffb389..d97f8486f0 100644
--- a/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-remoting
${revision}
+ ../pom.xml
dubbo-remoting-zookeeper
jar
diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
index c142d00941..75aa256b55 100644
--- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
+++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
@@ -46,6 +46,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
@@ -84,6 +85,10 @@ public class CuratorZookeeperClient extends AbstractZookeeperClientorg.apache.dubbo
dubbo-parent
${revision}
+ ../pom.xml
dubbo-remoting
pom
diff --git a/dubbo-rpc/dubbo-rpc-api/pom.xml b/dubbo-rpc/dubbo-rpc-api/pom.xml
index aae1c05b6e..d42cf3d13d 100644
--- a/dubbo-rpc/dubbo-rpc-api/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-api/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-api
jar
diff --git a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/filter/AccessLogFilterTest.java b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/filter/AccessLogFilterTest.java
index 3fc463fbad..5bfcb4b0dd 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/filter/AccessLogFilterTest.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/filter/AccessLogFilterTest.java
@@ -16,9 +16,6 @@
*/
package org.apache.dubbo.rpc.filter;
-import java.lang.reflect.Field;
-import java.util.Map;
-import java.util.Set;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.LogUtil;
import org.apache.dubbo.rpc.Filter;
@@ -30,6 +27,10 @@ import org.apache.dubbo.rpc.support.MyInvoker;
import org.junit.jupiter.api.Test;
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.Set;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
diff --git a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/BlockMyInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/BlockMyInvoker.java
index 7fec8d49fd..ee6e1bea9f 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/BlockMyInvoker.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/BlockMyInvoker.java
@@ -40,7 +40,7 @@ public class BlockMyInvoker extends MyInvoker {
@Override
public Result invoke(Invocation invocation) throws RpcException {
AppResponse result = new AppResponse();
- if (hasException == false) {
+ if (!hasException) {
try {
Thread.sleep(blockTime);
} catch (InterruptedException e) {
diff --git a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/MockInvokerTest.java b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/MockInvokerTest.java
index f3e3f179d2..fcfa091630 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/MockInvokerTest.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/MockInvokerTest.java
@@ -16,17 +16,18 @@
*/
package org.apache.dubbo.rpc.support;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.RpcInvocation;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.rpc.RpcException;
-import org.apache.dubbo.rpc.RpcInvocation;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
import static org.apache.dubbo.rpc.Constants.MOCK_KEY;
public class MockInvokerTest {
diff --git a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/MyInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/MyInvoker.java
index 57f1f1e6cc..ffccff64ea 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/MyInvoker.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/MyInvoker.java
@@ -60,7 +60,7 @@ public class MyInvoker implements Invoker {
public Result invoke(Invocation invocation) throws RpcException {
AppResponse result = new AppResponse();
- if (hasException == false) {
+ if (!hasException) {
result.setValue("alibaba");
} else {
result.setException(new RuntimeException("mocked exception"));
diff --git a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/RpcUtilsTest.java b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/RpcUtilsTest.java
index dc51234652..a3153aff0c 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/RpcUtilsTest.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/RpcUtilsTest.java
@@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcInvocation;
+
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -28,6 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static org.apache.dubbo.rpc.Constants.AUTO_ATTACH_INVOCATIONID_KEY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -35,8 +37,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
-import static org.apache.dubbo.rpc.Constants.AUTO_ATTACH_INVOCATIONID_KEY;
-
public class RpcUtilsTest {
/**
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/pom.xml b/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
index 99fdf5a8b9..858b710728 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-dubbo/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-dubbo
jar
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
index 529ac47b29..5cce20964d 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java
@@ -520,7 +520,7 @@ public class DubboProtocol extends AbstractProtocol {
}
/**
- * Add client references in bulk
+ * Increase the reference Count if we create new invoker shares same connection, the connection will be closed without any reference.
*
* @param referenceCountExchangeClients
*/
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
index c7074aa9db..bda87cae7f 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
@@ -192,6 +192,9 @@ final class ReferenceCountExchangeClient implements ExchangeClient {
return client.isClosed();
}
+ /**
+ * The reference count of current ExchangeClient, connection will be closed if all invokers destroyed.
+ */
public void incrementAndGetCount() {
referenceCount.incrementAndGet();
}
diff --git a/dubbo-rpc/dubbo-rpc-hessian/pom.xml b/dubbo-rpc/dubbo-rpc-hessian/pom.xml
index 99ef99da3c..5a0a8383e3 100644
--- a/dubbo-rpc/dubbo-rpc-hessian/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-hessian/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-hessian
jar
diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java
index 9e30d0d033..8415157837 100644
--- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java
@@ -48,11 +48,11 @@ import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
import static org.apache.dubbo.remoting.Constants.CLIENT_KEY;
import static org.apache.dubbo.remoting.Constants.DEFAULT_EXCHANGER;
import static org.apache.dubbo.rpc.Constants.GENERIC_KEY;
-import static org.apache.dubbo.rpc.protocol.hessian.Constants.HESSIAN2_REQUEST_KEY;
import static org.apache.dubbo.rpc.protocol.hessian.Constants.DEFAULT_HESSIAN2_REQUEST;
-import static org.apache.dubbo.rpc.protocol.hessian.Constants.HESSIAN_OVERLOAD_METHOD_KEY;
import static org.apache.dubbo.rpc.protocol.hessian.Constants.DEFAULT_HESSIAN_OVERLOAD_METHOD;
import static org.apache.dubbo.rpc.protocol.hessian.Constants.DEFAULT_HTTP_CLIENT;
+import static org.apache.dubbo.rpc.protocol.hessian.Constants.HESSIAN2_REQUEST_KEY;
+import static org.apache.dubbo.rpc.protocol.hessian.Constants.HESSIAN_OVERLOAD_METHOD_KEY;
/**
* http rpc support.
diff --git a/dubbo-rpc/dubbo-rpc-http/pom.xml b/dubbo-rpc/dubbo-rpc-http/pom.xml
index 6681a9a632..76cf8ab92d 100644
--- a/dubbo-rpc/dubbo-rpc-http/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-http/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-http
jar
diff --git a/dubbo-rpc/dubbo-rpc-injvm/pom.xml b/dubbo-rpc/dubbo-rpc-injvm/pom.xml
index 53ed2ffb4e..b5562bd13c 100644
--- a/dubbo-rpc/dubbo-rpc-injvm/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-injvm/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-injvm
jar
diff --git a/dubbo-rpc/dubbo-rpc-jsonrpc/pom.xml b/dubbo-rpc/dubbo-rpc-jsonrpc/pom.xml
index c5b4e89038..0963763dd3 100644
--- a/dubbo-rpc/dubbo-rpc-jsonrpc/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-jsonrpc/pom.xml
@@ -21,6 +21,7 @@
dubbo-rpc
org.apache.dubbo
${revision}
+ ../pom.xml
4.0.0
diff --git a/dubbo-rpc/dubbo-rpc-memcached/pom.xml b/dubbo-rpc/dubbo-rpc-memcached/pom.xml
index bcfeea67e6..1a055206f5 100644
--- a/dubbo-rpc/dubbo-rpc-memcached/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-memcached/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-memcached
jar
diff --git a/dubbo-rpc/dubbo-rpc-native-thrift/pom.xml b/dubbo-rpc/dubbo-rpc-native-thrift/pom.xml
index bcc3cf9ec8..4aa998c0e7 100644
--- a/dubbo-rpc/dubbo-rpc-native-thrift/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-native-thrift/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-native-thrift
jar
diff --git a/dubbo-rpc/dubbo-rpc-redis/pom.xml b/dubbo-rpc/dubbo-rpc-redis/pom.xml
index 123273215f..7734033451 100644
--- a/dubbo-rpc/dubbo-rpc-redis/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-redis/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-redis
jar
diff --git a/dubbo-rpc/dubbo-rpc-rest/pom.xml b/dubbo-rpc/dubbo-rpc-rest/pom.xml
index b162030fd8..d5a97e0242 100644
--- a/dubbo-rpc/dubbo-rpc-rest/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-rest/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-rest
jar
diff --git a/dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/integration/swagger/DubboSwaggerApiListingResourceTest.java b/dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/integration/swagger/DubboSwaggerApiListingResourceTest.java
index 64f8b5da1c..565ddf75d5 100644
--- a/dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/integration/swagger/DubboSwaggerApiListingResourceTest.java
+++ b/dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/integration/swagger/DubboSwaggerApiListingResourceTest.java
@@ -25,12 +25,12 @@ import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;
-
import java.net.URI;
import java.util.HashSet;
import java.util.Set;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class DubboSwaggerApiListingResourceTest {
diff --git a/dubbo-rpc/dubbo-rpc-rmi/pom.xml b/dubbo-rpc/dubbo-rpc-rmi/pom.xml
index 7e560b2cb9..1c7d3273f3 100644
--- a/dubbo-rpc/dubbo-rpc-rmi/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-rmi/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-rmi
jar
diff --git a/dubbo-rpc/dubbo-rpc-rmi/src/test/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocolTest.java b/dubbo-rpc/dubbo-rpc-rmi/src/test/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocolTest.java
index 9f3cb332c3..dcb3f68a45 100644
--- a/dubbo-rpc/dubbo-rpc-rmi/src/test/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocolTest.java
+++ b/dubbo-rpc/dubbo-rpc-rmi/src/test/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocolTest.java
@@ -20,13 +20,13 @@ package org.apache.dubbo.rpc.protocol.rmi;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.rpc.Exporter;
+import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.ProxyFactory;
import org.apache.dubbo.rpc.RpcException;
-import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.service.EchoService;
-
import org.apache.dubbo.rpc.service.GenericService;
+
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
diff --git a/dubbo-rpc/dubbo-rpc-thrift/pom.xml b/dubbo-rpc/dubbo-rpc-thrift/pom.xml
index d6e20ed95e..e6c21304fe 100644
--- a/dubbo-rpc/dubbo-rpc-thrift/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-thrift/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-thrift
jar
diff --git a/dubbo-rpc/dubbo-rpc-webservice/pom.xml b/dubbo-rpc/dubbo-rpc-webservice/pom.xml
index 70078f8f1a..ff08b3804b 100644
--- a/dubbo-rpc/dubbo-rpc-webservice/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-webservice/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-webservice
jar
diff --git a/dubbo-rpc/dubbo-rpc-xml/pom.xml b/dubbo-rpc/dubbo-rpc-xml/pom.xml
index 9afede914b..bd45e0fe22 100644
--- a/dubbo-rpc/dubbo-rpc-xml/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-xml/pom.xml
@@ -21,6 +21,7 @@
org.apache.dubbo
dubbo-rpc
${revision}
+ ../pom.xml
dubbo-rpc-xml
diff --git a/dubbo-rpc/dubbo-rpc-xml/src/main/java/org/apache/dubbo/xml/rpc/protocol/xmlrpc/XmlRpcProtocol.java b/dubbo-rpc/dubbo-rpc-xml/src/main/java/org/apache/dubbo/xml/rpc/protocol/xmlrpc/XmlRpcProtocol.java
index 83b36cd69d..5e5efbab9e 100644
--- a/dubbo-rpc/dubbo-rpc-xml/src/main/java/org/apache/dubbo/xml/rpc/protocol/xmlrpc/XmlRpcProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-xml/src/main/java/org/apache/dubbo/xml/rpc/protocol/xmlrpc/XmlRpcProtocol.java
@@ -150,8 +150,8 @@ public class XmlRpcProtocol extends AbstractProxyProtocol {
}
@Override
- @SuppressWarnings("unchecked")
protected T doRefer(final Class serviceType, URL url) throws RpcException {
+ @SuppressWarnings("unchecked")
XmlRpcProxyFactoryBean xmlRpcProxyFactoryBean = new XmlRpcProxyFactoryBean();
xmlRpcProxyFactoryBean.setServiceUrl(url.setProtocol("http").toIdentityString());
xmlRpcProxyFactoryBean.setServiceInterface(serviceType);
diff --git a/dubbo-rpc/pom.xml b/dubbo-rpc/pom.xml
index 44b064f697..1388b5018b 100644
--- a/dubbo-rpc/pom.xml
+++ b/dubbo-rpc/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-parent
${revision}
+ ../pom.xml
dubbo-rpc
pom
diff --git a/dubbo-serialization/dubbo-serialization-api/pom.xml b/dubbo-serialization/dubbo-serialization-api/pom.xml
index 62cf6f3105..f76044ced2 100644
--- a/dubbo-serialization/dubbo-serialization-api/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-api/pom.xml
@@ -21,6 +21,7 @@ limitations under the License.
org.apache.dubbo
dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-api
jar
diff --git a/dubbo-serialization/dubbo-serialization-avro/pom.xml b/dubbo-serialization/dubbo-serialization-avro/pom.xml
index 908c49eb2f..75bbff7799 100644
--- a/dubbo-serialization/dubbo-serialization-avro/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-avro/pom.xml
@@ -21,6 +21,7 @@
org.apache.dubbo
dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-avro
jar
diff --git a/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectInput.java b/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectInput.java
index 8dc8057727..0d85ec7b24 100644
--- a/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectInput.java
+++ b/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectInput.java
@@ -16,11 +16,12 @@
*/
package org.apache.dubbo.common.serialize.avro;
+import org.apache.dubbo.common.serialize.ObjectInput;
+
import org.apache.avro.io.BinaryDecoder;
import org.apache.avro.io.DecoderFactory;
import org.apache.avro.reflect.ReflectDatumReader;
import org.apache.avro.util.Utf8;
-import org.apache.dubbo.common.serialize.ObjectInput;
import java.io.IOException;
import java.io.InputStream;
diff --git a/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectOutput.java b/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectOutput.java
index e723063a4f..42a34e05f0 100644
--- a/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectOutput.java
+++ b/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectOutput.java
@@ -16,11 +16,12 @@
*/
package org.apache.dubbo.common.serialize.avro;
+import org.apache.dubbo.common.serialize.ObjectOutput;
+
import org.apache.avro.io.BinaryEncoder;
import org.apache.avro.io.EncoderFactory;
import org.apache.avro.reflect.ReflectDatumWriter;
import org.apache.avro.util.Utf8;
-import org.apache.dubbo.common.serialize.ObjectOutput;
import java.io.IOException;
import java.io.OutputStream;
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/pom.xml b/dubbo-serialization/dubbo-serialization-fastjson/pom.xml
index 6553abd7ec..48bd0c6da7 100644
--- a/dubbo-serialization/dubbo-serialization-fastjson/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-fastjson/pom.xml
@@ -21,6 +21,7 @@ limitations under the License.
org.apache.dubbo
dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-fastjson
jar
diff --git a/dubbo-serialization/dubbo-serialization-fst/pom.xml b/dubbo-serialization/dubbo-serialization-fst/pom.xml
index 1f2936e8dd..7bcaaf8d49 100644
--- a/dubbo-serialization/dubbo-serialization-fst/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-fst/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-fst
jar
diff --git a/dubbo-serialization/dubbo-serialization-gson/pom.xml b/dubbo-serialization/dubbo-serialization-gson/pom.xml
index 3822d37755..52e1588a17 100644
--- a/dubbo-serialization/dubbo-serialization-gson/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-gson/pom.xml
@@ -20,6 +20,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
dubbo-serialization
org.apache.dubbo
${revision}
+ ../pom.xml
dubbo-serialization-gson
jar
diff --git a/dubbo-serialization/dubbo-serialization-hessian2/pom.xml b/dubbo-serialization/dubbo-serialization-hessian2/pom.xml
index 9363daca43..99a966ca6c 100644
--- a/dubbo-serialization/dubbo-serialization-hessian2/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-hessian2/pom.xml
@@ -21,6 +21,7 @@ limitations under the License.
org.apache.dubbo
dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-hessian2
jar
diff --git a/dubbo-serialization/dubbo-serialization-jdk/pom.xml b/dubbo-serialization/dubbo-serialization-jdk/pom.xml
index 21df9f487e..7058dbde4a 100644
--- a/dubbo-serialization/dubbo-serialization-jdk/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-jdk/pom.xml
@@ -21,6 +21,7 @@ limitations under the License.
org.apache.dubbo
dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-jdk
jar
diff --git a/dubbo-serialization/dubbo-serialization-kryo/pom.xml b/dubbo-serialization/dubbo-serialization-kryo/pom.xml
index 86b5083a06..9e22ed0b57 100644
--- a/dubbo-serialization/dubbo-serialization-kryo/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-kryo/pom.xml
@@ -21,6 +21,7 @@ limitations under the License.
org.apache.dubbo
dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-kryo
jar
diff --git a/dubbo-serialization/dubbo-serialization-native-hession/pom.xml b/dubbo-serialization/dubbo-serialization-native-hession/pom.xml
index 8d641db13c..8c710f6e9e 100644
--- a/dubbo-serialization/dubbo-serialization-native-hession/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-native-hession/pom.xml
@@ -17,9 +17,10 @@ limitations under the License.
- dubbo-serialization
org.apache.dubbo
+ dubbo-serialization
${revision}
+ ../pom.xml
4.0.0
diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/pom.xml b/dubbo-serialization/dubbo-serialization-protobuf-json/pom.xml
index b0788e1872..c39e288f93 100644
--- a/dubbo-serialization/dubbo-serialization-protobuf-json/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-protobuf-json/pom.xml
@@ -17,9 +17,10 @@ limitations under the License.
4.0.0
- dubbo-serialization
org.apache.dubbo
+ dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-protobuf-json
jar
diff --git a/dubbo-serialization/dubbo-serialization-protostuff/pom.xml b/dubbo-serialization/dubbo-serialization-protostuff/pom.xml
index 7d9e2c8e87..1682cbb853 100644
--- a/dubbo-serialization/dubbo-serialization-protostuff/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-protostuff/pom.xml
@@ -18,9 +18,10 @@ limitations under the License.
4.0.0
- dubbo-serialization
org.apache.dubbo
+ dubbo-serialization
${revision}
+ ../pom.xml
dubbo-serialization-protostuff
diff --git a/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/utils/WrapperUtils.java b/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/utils/WrapperUtils.java
index 80a67efc92..321ed0dcbd 100644
--- a/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/utils/WrapperUtils.java
+++ b/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/utils/WrapperUtils.java
@@ -20,10 +20,10 @@ package org.apache.dubbo.common.serialize.protostuff.utils;
import org.apache.dubbo.common.serialize.protostuff.Wrapper;
import org.apache.dubbo.common.serialize.protostuff.delegate.SqlDateDelegate;
import org.apache.dubbo.common.serialize.protostuff.delegate.TimeDelegate;
+import org.apache.dubbo.common.serialize.protostuff.delegate.TimestampDelegate;
import io.protostuff.runtime.DefaultIdStrategy;
import io.protostuff.runtime.RuntimeEnv;
-import org.apache.dubbo.common.serialize.protostuff.delegate.TimestampDelegate;
import java.math.BigDecimal;
import java.sql.Time;
diff --git a/dubbo-serialization/dubbo-serialization-test/pom.xml b/dubbo-serialization/dubbo-serialization-test/pom.xml
index 60d0c5ff0f..6799a9cdf1 100644
--- a/dubbo-serialization/dubbo-serialization-test/pom.xml
+++ b/dubbo-serialization/dubbo-serialization-test/pom.xml
@@ -17,9 +17,10 @@
- dubbo-serialization
org.apache.dubbo
+ dubbo-serialization
${revision}
+ ../pom.xml
4.0.0
diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2PersonOkTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2PersonOkTest.java
index 3d454b2c39..2abad1e852 100644
--- a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2PersonOkTest.java
+++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2PersonOkTest.java
@@ -19,6 +19,7 @@ package org.apache.dubbo.common.serialize.hessian2;
import org.apache.dubbo.common.serialize.ObjectInput;
import org.apache.dubbo.common.serialize.ObjectOutput;
import org.apache.dubbo.common.serialize.base.AbstractSerializationPersonOkTest;
+
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutputTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutputTest.java
index 8f9b08da96..2d7a86aa2e 100644
--- a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutputTest.java
+++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufObjectOutputTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.common.serialize.protobuf.support;
import org.apache.dubbo.common.serialize.protobuf.support.model.GooglePB;
+
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffObjectOutputTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffObjectOutputTest.java
index 52397920f0..0ae337a5cb 100644
--- a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffObjectOutputTest.java
+++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffObjectOutputTest.java
@@ -16,9 +16,8 @@
*/
package org.apache.dubbo.common.serialize.protostuff;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -26,8 +25,9 @@ import java.io.IOException;
import java.sql.Timestamp;
import java.util.Date;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.nullValue;
public class ProtostuffObjectOutputTest {
diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java
index 8f5a9de13f..35027b5c02 100644
--- a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java
+++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java
@@ -18,12 +18,13 @@ package org.apache.dubbo.common.serialize.support;
import org.apache.dubbo.common.serialize.model.SerializablePerson;
import org.apache.dubbo.common.serialize.model.person.Phone;
+
import org.junit.jupiter.api.Test;
import java.util.Map;
-import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
public class SerializableClassRegistryTest {
@Test
diff --git a/dubbo-serialization/pom.xml b/dubbo-serialization/pom.xml
index 448aa07862..31e4175d43 100644
--- a/dubbo-serialization/pom.xml
+++ b/dubbo-serialization/pom.xml
@@ -20,6 +20,7 @@
org.apache.dubbo
dubbo-parent
${revision}
+ ../pom.xml
dubbo-serialization
pom