You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/08/27 05:51:04 UTC
[dubbo] branch 3.0 updated: Adjust the acquisition of the app, group,
and version value of the url (#8582)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new d386cd5 Adjust the acquisition of the app, group, and version value of the url (#8582)
d386cd5 is described below
commit d386cd5f071634b739d19a2fdfb0e816a79dc56e
Author: 灼华 <43...@users.noreply.github.com>
AuthorDate: Fri Aug 27 13:50:53 2021 +0800
Adjust the acquisition of the app, group, and version value of the url (#8582)
* Adjust the acquisition of the app, group, and version value of the url
* FIX
---
.../dubbo/rpc/cluster/router/condition/config/AppRouter.java | 3 +--
.../src/test/java/org/apache/dubbo/config/ServiceConfigTest.java | 6 ++----
...istryCenterServiceDiscoveryRegistryRegistryServiceListener.java | 3 +--
.../main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java | 2 +-
.../java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java | 2 +-
.../java/org/apache/dubbo/registry/multiple/MultipleRegistry.java | 2 +-
.../apache/dubbo/registry/multiple/MultipleServiceDiscovery.java | 2 +-
.../src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java | 7 ++-----
8 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/AppRouter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/AppRouter.java
index e12b202..abc1925 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/AppRouter.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/AppRouter.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.rpc.cluster.router.condition.config;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.CommonConstants;
/**
* Application level router, "application.condition-router"
@@ -30,7 +29,7 @@ public class AppRouter extends ListenableRouter {
private static final int APP_ROUTER_DEFAULT_PRIORITY = 150;
public AppRouter(URL url) {
- super(url, url.getParameter(CommonConstants.APPLICATION_KEY));
+ super(url, url.getApplication());
this.setPriority(APP_ROUTER_DEFAULT_PRIORITY);
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java
index a9cd67f..18a35bd 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java
@@ -51,13 +51,11 @@ import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_SERIALIZATION_BEAN;
import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_SERIALIZATION_DEFAULT;
import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_SERIALIZATION_NATIVE_JAVA;
-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.METHODS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
-import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.config.Constants.SHUTDOWN_TIMEOUT_KEY;
import static org.apache.dubbo.remoting.Constants.BIND_IP_KEY;
import static org.apache.dubbo.remoting.Constants.BIND_PORT_KEY;
@@ -184,10 +182,10 @@ public class ServiceConfigTest {
service.export();
String serviceVersion = service.getVersion();
- String serviceVersion2 = service.toUrl().getParameter(VERSION_KEY);
+ String serviceVersion2 = service.toUrl().getVersion();
String group = service.getGroup();
- String group2 = service.toUrl().getParameter(GROUP_KEY);
+ String group2 = service.toUrl().getGroup();
assertEquals(serviceVersion2, serviceVersion);
assertEquals(group, group2);
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java
index a1dd4d7..3d4fed5 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.metadata.WritableMetadataService;
import org.apache.dubbo.registry.Registry;
@@ -49,7 +48,7 @@ public class MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListen
* Checks if the registry is checked application
*/
private boolean isCheckedApplication(Registry registry){
- return registry.getUrl().getParameter(CommonConstants.APPLICATION_KEY)
+ return registry.getUrl().getApplication()
.equals(MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest
.PROVIDER_APPLICATION_NAME);
}
diff --git a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java
index 1ba1b17..dc59165 100644
--- a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java
+++ b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java
@@ -32,7 +32,7 @@ public class AccessKeyAuthenticator implements Authenticator {
@Override
public void sign(Invocation invocation, URL url) {
String currentTime = String.valueOf(System.currentTimeMillis());
- String consumer = url.getParameter(CommonConstants.APPLICATION_KEY);
+ String consumer = url.getApplication();
AccessKeyPair accessKeyPair = getAccessKeyPair(invocation, url);
invocation.setAttachment(Constants.REQUEST_SIGNATURE_KEY, getSignature(url, invocation, accessKeyPair.getSecretKey(), currentTime));
invocation.setAttachment(Constants.REQUEST_TIMESTAMP_KEY, currentTime);
diff --git a/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java b/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java
index 946a4e5..5a0cfb2 100644
--- a/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java
+++ b/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java
@@ -58,7 +58,7 @@ class AccessKeyAuthenticatorTest {
when(helper.getAccessKeyPair(invocation, url)).thenReturn(accessKeyPair);
helper.sign(invocation, url);
- assertEquals(String.valueOf(invocation.getAttachment(CommonConstants.CONSUMER)), url.getParameter(CommonConstants.APPLICATION_KEY));
+ assertEquals(String.valueOf(invocation.getAttachment(CommonConstants.CONSUMER)), url.getApplication());
assertNotNull(invocation.getAttachments().get(Constants.REQUEST_SIGNATURE_KEY));
assertEquals(invocation.getAttachments().get(Constants.REQUEST_SIGNATURE_KEY), "dubbo");
}
diff --git a/dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleRegistry.java b/dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleRegistry.java
index 8ad2c10..ea2758b 100644
--- a/dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleRegistry.java
+++ b/dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleRegistry.java
@@ -68,7 +68,7 @@ public class MultipleRegistry extends AbstractRegistry {
public MultipleRegistry(URL url, boolean initServiceRegistry, boolean initReferenceRegistry) {
super(url);
this.registryUrl = url;
- this.applicationName = url.getParameter(CommonConstants.APPLICATION_KEY);
+ this.applicationName = url.getApplication();
init();
checkApplicationName(this.applicationName);
// This urls contain parameter and it donot inherit from the parameter of url in MultipleRegistry
diff --git a/dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleServiceDiscovery.java b/dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleServiceDiscovery.java
index 068b6d3..8ca95f6 100644
--- a/dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleServiceDiscovery.java
+++ b/dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleServiceDiscovery.java
@@ -45,7 +45,7 @@ public class MultipleServiceDiscovery implements ServiceDiscovery {
@Override
public void initialize(URL registryURL) throws Exception {
this.registryURL = registryURL;
- this.applicationName = registryURL.getParameter(CommonConstants.APPLICATION_KEY);
+ this.applicationName = registryURL.getApplication();
Map<String, String> parameters = registryURL.getParameters();
for (String key : parameters.keySet()) {
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java
index c67b68a..455a47f 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java
@@ -30,9 +30,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
-import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
-
/**
* AccessLogData is a container for log event data. In internally uses map and store each filed of log as value. It
* does not generate any dynamic value e.g. time stamp, local jmv machine host address etc. It does not allow any null
@@ -271,8 +268,8 @@ public final class AccessLogData {
public void buildAccessLogData(Invoker<?> invoker, Invocation inv) {
setServiceName(invoker.getInterface().getName());
setMethodName(inv.getMethodName());
- setVersion(invoker.getUrl().getParameter(VERSION_KEY));
- setGroup(invoker.getUrl().getParameter(GROUP_KEY));
+ setVersion(invoker.getUrl().getVersion());
+ setGroup(invoker.getUrl().getGroup());
setInvocationTime(new Date());
setTypes(inv.getParameterTypes());
setArguments(inv.getArguments());