diff --git
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java
index da5e04d13d..8901e4cace 100644
---
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java
+++
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java
@@ -18,6 +18,7 @@
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.utils.StringUtils;
import java.util.HashMap;
import java.util.HashSet;
@@ -81,8 +82,14 @@ public static URL mergeUrl(URL remoteUrl, Map<String,
String> localMap) {
// So, generally, we don't need to care about the group value here.
// But when comes to group merger, there is an exception, the
consumer group may be '*' while the provider group can be empty or any other
values.
String remoteGroup = map.get(Constants.GROUP_KEY);
+ String remoteRelease = map.get(Constants.RELEASE_KEY);
map.putAll(localMap);
map.put(Constants.GROUP_KEY, remoteGroup);
+ // we should always keep the Provider RELEASE_KEY not overrode by
the the value on Consumer side.
+ map.remove(Constants.RELEASE_KEY);
+ if (StringUtils.isNotEmpty(remoteRelease)) {
+ map.put(Constants.RELEASE_KEY, remoteRelease);
+ }
}
if (remoteMap != null && remoteMap.size() > 0) {
// Use version passed from provider side
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
index 1a2f5536ac..6d8313c53b 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
@@ -749,9 +749,9 @@
public static final String COMPATIBLE_CONFIG_KEY = "compatible_config";
// package version in the manifest
- public static final String SPECIFICATION_VERSION_KEY = "specVersion";
+ public static final String RELEASE_KEY = "release";
- public static final String OVERRIDE_PROVIDERS_KEY = "providerAddreses";
+ public static final String OVERRIDE_PROVIDERS_KEY = "providerAddresses";
public static final String PROTOCOLS_SUFFIX = "dubbo.protocols.";
@@ -760,9 +760,9 @@
public static final String REGISTRIES_SUFFIX = "dubbo.registries.";
public static final String[] DEFAULT_REGISTER_PROVIDER_KEYS =
{APPLICATION_KEY, CODEC_KEY, EXCHANGER_KEY, SERIALIZATION_KEY, CLUSTER_KEY,
CONNECTIONS_KEY, DEPRECATED_KEY,
- GROUP_KEY, LOADBALANCE_KEY, MOCK_KEY, PATH_KEY, TIMEOUT_KEY,
TOKEN_KEY, VERSION_KEY, WARMUP_KEY, WEIGHT_KEY, TIMESTAMP_KEY,
DUBBO_VERSION_KEY, SPECIFICATION_VERSION_KEY};
+ GROUP_KEY, LOADBALANCE_KEY, MOCK_KEY, PATH_KEY, TIMEOUT_KEY,
TOKEN_KEY, VERSION_KEY, WARMUP_KEY, WEIGHT_KEY, TIMESTAMP_KEY,
DUBBO_VERSION_KEY, RELEASE_KEY};
- public static final String[] DEFAULT_REGISTER_CONSUMER_KEYS =
{APPLICATION_KEY, VERSION_KEY, GROUP_KEY, DUBBO_VERSION_KEY,
SPECIFICATION_VERSION_KEY};
+ public static final String[] DEFAULT_REGISTER_CONSUMER_KEYS =
{APPLICATION_KEY, VERSION_KEY, GROUP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY};
public static final String TELNET = "telnet";
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
index 9e5893fc76..4c5ef9c47c 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
@@ -19,6 +19,7 @@
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ClassHelper;
+import org.apache.dubbo.common.utils.StringUtils;
import java.net.URL;
import java.security.CodeSource;
@@ -41,9 +42,10 @@
/**
* For protocol compatibility purpose.
- * Because {@link #isSupportResponseAttachment} is checked for every call,
int compare expect to has higher performance than string.
+ * Because {@link #isSupportResponseAttachment} is checked for every call,
int compare expect to has higher
+ * performance than string.
*/
- private static final int LOWEST_VERSION_FOR_RESPONSE_ATTACHMENT = 20002;
// 2.0.2
+ private static final int LOWEST_VERSION_FOR_RESPONSE_ATTACHMENT = 2000200;
// 2.0.2
private static final Map<String, Integer> VERSION2INT = new
HashMap<String, Integer>();
static {
@@ -62,13 +64,38 @@ public static String getVersion() {
return VERSION;
}
+ /**
+ * To check the framework release version number to decide if it's 2.7.0
or higher
+ */
+ public static boolean isFramework270OrHigher (String version) {
+ if (StringUtils.isEmpty(version)) {
+ return false;
+ }
+ if (getIntVersion(version) >= 2070000) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * To check the framework release version number to decide if it's 2.6.3
or higher
+ *
+ * Because response attachments feature is firstly introduced in 2.6.3
+ * and moreover we have no other approach to check the framework version
number, so we use
+ * isSupportResponseAttachment to decide if it's v2.6.3
+ */
+ public static boolean isFramework263OrHigher (String version) {
+ return isSupportResponseAttachment(version);
+ }
+
public static boolean isSupportResponseAttachment(String version) {
if (version == null || version.length() == 0) {
return false;
}
- // for previous dubbo version(2.0.10/020010~2.6.2/020602), this
version is the jar's version, so they need to be ignore
+ // for previous dubbo version(2.0.10/020010~2.6.2/020602), this
version is the jar's version, so they need to
+ // be ignore
int iVersion = getIntVersion(version);
- if (iVersion >= 20010 && iVersion <= 20602) {
+ if (iVersion >= 2001000 && iVersion <= 2060200) {
return false;
}
@@ -79,6 +106,10 @@ public static int getIntVersion(String version) {
Integer v = VERSION2INT.get(version);
if (v == null) {
v = parseInt(version);
+ // e.g., version number 2.6.3 will convert to 2060300
+ if (version.split("\\.").length == 3) {
+ v = v * 100;
+ }
VERSION2INT.put(version, v);
}
return v;
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/common/version/VersionTest.java
b/dubbo-common/src/test/java/org/apache/dubbo/common/version/VersionTest.java
index a129f53e58..032c22d2fa 100644
---
a/dubbo-common/src/test/java/org/apache/dubbo/common/version/VersionTest.java
+++
b/dubbo-common/src/test/java/org/apache/dubbo/common/version/VersionTest.java
@@ -35,4 +35,32 @@ public void testSupportResponseAttachment() {
Assert.assertTrue(Version.isSupportResponseAttachment("2.0.3"));
Assert.assertFalse(Version.isSupportResponseAttachment("2.0.0"));
}
+
+ @Test
+ public void testGetIntVersion() {
+ Assert.assertEquals(2060100, Version.getIntVersion("2.6.1"));
+ Assert.assertEquals(2060101, Version.getIntVersion("2.6.1.1"));
+ Assert.assertEquals(2070001, Version.getIntVersion("2.7.0.1"));
+ Assert.assertEquals(2070000, Version.getIntVersion("2.7.0"));
+ }
+
+ @Test
+ public void testIsFramework270OrHigher() {
+ Assert.assertTrue(Version.isFramework270OrHigher("2.7.0"));
+ Assert.assertTrue(Version.isFramework270OrHigher("2.7.0.1"));
+ Assert.assertTrue(Version.isFramework270OrHigher("2.7.0.2"));
+ Assert.assertTrue(Version.isFramework270OrHigher("2.8.0"));
+ Assert.assertFalse(Version.isFramework270OrHigher("2.6.3"));
+ Assert.assertFalse(Version.isFramework270OrHigher("2.6.3.1"));
+ }
+
+ @Test
+ public void testIsFramework263OrHigher() {
+ Assert.assertTrue(Version.isFramework263OrHigher("2.7.0"));
+ Assert.assertTrue(Version.isFramework263OrHigher("2.7.0.1"));
+ Assert.assertTrue(Version.isFramework263OrHigher("2.6.4"));
+ Assert.assertFalse(Version.isFramework263OrHigher("2.6.2"));
+ Assert.assertFalse(Version.isFramework263OrHigher("2.6.1.1"));
+ Assert.assertTrue(Version.isFramework263OrHigher("2.6.3"));
+ }
}
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
index b9d61732c9..27d2b4b7d7 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
@@ -363,7 +363,7 @@ protected URL loadMonitor(URL registryURL) {
static void appendRuntimeParameters(Map<String, String> map) {
map.put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion());
- map.put(Constants.SPECIFICATION_VERSION_KEY, Version.getVersion());
+ map.put(Constants.RELEASE_KEY, Version.getVersion());
map.put(Constants.TIMESTAMP_KEY,
String.valueOf(System.currentTimeMillis()));
if (ConfigUtils.getPid() > 0) {
map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid()));
diff --git
a/dubbo-rpc/dubbo-rpc-http/src/main/java/com/alibaba/dubbo/rpc/protocol/http/HttpRemoteInvocation.java
b/dubbo-rpc/dubbo-rpc-http/src/main/java/com/alibaba/dubbo/rpc/protocol/http/HttpRemoteInvocation.java
new file mode 100644
index 0000000000..3e923b67a0
--- /dev/null
+++
b/dubbo-rpc/dubbo-rpc-http/src/main/java/com/alibaba/dubbo/rpc/protocol/http/HttpRemoteInvocation.java
@@ -0,0 +1,28 @@
+/*
+ * 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 com.alibaba.dubbo.rpc.protocol.http;
+
+import org.aopalliance.intercept.MethodInvocation;
+
+@Deprecated
+public class HttpRemoteInvocation extends
org.apache.dubbo.rpc.protocol.http.HttpRemoteInvocation {
+ private static final long serialVersionUID = 1L;
+
+ public HttpRemoteInvocation(MethodInvocation methodInvocation) {
+ super(methodInvocation);
+ }
+}
diff --git
a/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java
b/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java
index ba4bb4f243..8246f348c6 100644
---
a/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java
+++
b/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java
@@ -18,6 +18,7 @@
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.Version;
import org.apache.dubbo.remoting.http.HttpBinder;
import org.apache.dubbo.remoting.http.HttpHandler;
import org.apache.dubbo.remoting.http.HttpServer;
@@ -116,7 +117,27 @@ public void run() {
httpProxyFactoryBean.setRemoteInvocationFactory(new
RemoteInvocationFactory() {
@Override
public RemoteInvocation createRemoteInvocation(MethodInvocation
methodInvocation) {
- RemoteInvocation invocation = new
HttpRemoteInvocation(methodInvocation);
+ RemoteInvocation invocation;
+ /*
+ package was renamed to 'org.apache.dubbo' in v2.7.0, so only
provider versions after v2.7.0 can
+ recognize org.apache.xxx.HttpRemoteInvocation'.
+ */
+ if
(Version.isFramework270OrHigher(url.getParameter(Constants.RELEASE_KEY))) {
+ invocation = new HttpRemoteInvocation(methodInvocation);
+ } else {
+ /*
+ The customized
'com.alibaba.dubbo.rpc.protocol.http.HttpRemoteInvocation' was firstly
introduced
+ in v2.6.3. The main purpose is to support transformation
of attachments in HttpProtocol:
+ https://github.com/apache/incubator-dubbo/pull/1827. To
guarantee interoperability with lower
+ versions, we need to check if the provider is v2.6.3 or
higher before sending customized
+ HttpRemoteInvocation.
+ */
+ if
(Version.isFramework263OrHigher(url.getParameter(Constants.DUBBO_VERSION_KEY)))
{
+ invocation = new
com.alibaba.dubbo.rpc.protocol.http.HttpRemoteInvocation(methodInvocation);
+ } else {
+ invocation = new RemoteInvocation(methodInvocation);
+ }
+ }
if (isGeneric) {
invocation.addAttribute(Constants.GENERIC_KEY, generic);
}
diff --git
a/dubbo-rpc/dubbo-rpc-http/src/test/java/org/apache/dubbo/rpc/protocol/http/HttpProtocolTest.java
b/dubbo-rpc/dubbo-rpc-http/src/test/java/org/apache/dubbo/rpc/protocol/http/HttpProtocolTest.java
index 2c75e6da85..1ff5438a3f 100644
---
a/dubbo-rpc/dubbo-rpc-http/src/test/java/org/apache/dubbo/rpc/protocol/http/HttpProtocolTest.java
+++
b/dubbo-rpc/dubbo-rpc-http/src/test/java/org/apache/dubbo/rpc/protocol/http/HttpProtocolTest.java
@@ -46,7 +46,7 @@ public void testHttpProtocol() {
Assert.assertFalse(server.isCalled());
ProxyFactory proxyFactory =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?version=1.0.0");
+ URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?release=2.7.0");
Exporter<HttpService> exporter =
protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
Invoker<HttpService> invoker = protocol.refer(HttpService.class, url);
HttpService client = proxyFactory.getProxy(invoker);
@@ -63,7 +63,7 @@ public void testGenericInvoke() {
Assert.assertFalse(server.isCalled());
ProxyFactory proxyFactory =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?version=1.0.0");
+ URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?release=2.7.0");
Exporter<HttpService> exporter =
protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
Invoker<GenericService> invoker = protocol.refer(GenericService.class,
url);
GenericService client = proxyFactory.getProxy(invoker, true);
@@ -80,7 +80,7 @@ public void testGenericInvokeWithNativeJava() throws
IOException, ClassNotFoundE
Assert.assertFalse(server.isCalled());
ProxyFactory proxyFactory =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?version=1.0.0&generic=nativejava");
+ URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?release=2.7.0&generic=nativejava");
Exporter<HttpService> exporter =
protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
Invoker<GenericService> invoker = protocol.refer(GenericService.class,
url);
GenericService client = proxyFactory.getProxy(invoker);
@@ -107,7 +107,7 @@ public void testGenericInvokeWithBean() {
Assert.assertFalse(server.isCalled());
ProxyFactory proxyFactory =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?version=1.0.0&generic=bean");
+ URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?release=2.7.0&generic=bean");
Exporter<HttpService> exporter =
protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
Invoker<GenericService> invoker = protocol.refer(GenericService.class,
url);
GenericService client = proxyFactory.getProxy(invoker);
@@ -127,7 +127,7 @@ public void testOverload() {
Assert.assertFalse(server.isCalled());
ProxyFactory proxyFactory =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() +
"?version=1.0.0&hessian.overload.method=true&hessian2.request=false");
+ URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() +
"?release=2.7.0&hessian.overload.method=true&hessian2.request=false");
Exporter<HttpService> exporter =
protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
Invoker<HttpService> invoker = protocol.refer(HttpService.class, url);
HttpService client = proxyFactory.getProxy(invoker);
@@ -145,7 +145,7 @@ public void testSimpleClient() {
Assert.assertFalse(server.isCalled());
ProxyFactory proxyFactory =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?version=1.0.0&client=simple");
+ URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?release=2.7.0&client=simple");
Exporter<HttpService> exporter =
protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
Invoker<HttpService> invoker = protocol.refer(HttpService.class, url);
HttpService client = proxyFactory.getProxy(invoker);
@@ -161,7 +161,7 @@ public void testTimeOut() {
HttpServiceImpl server = new HttpServiceImpl();
ProxyFactory proxyFactory =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?version=1.0.0&timeout=10");
+ URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?release=2.7.0&timeout=10");
Exporter<HttpService> exporter =
protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
Invoker<HttpService> invoker = protocol.refer(HttpService.class, url);
HttpService client = proxyFactory.getProxy(invoker);
@@ -182,7 +182,7 @@ public void testCustomException() {
HttpServiceImpl server = new HttpServiceImpl();
ProxyFactory proxyFactory =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?version=1.0.0");
+ URL url = URL.valueOf("http://127.0.0.1:5342/" +
HttpService.class.getName() + "?release=2.7.0");
Exporter<HttpService> exporter =
protocol.export(proxyFactory.getInvoker(server, HttpService.class, url));
Invoker<HttpService> invoker = protocol.refer(HttpService.class, url);
HttpService client = proxyFactory.getProxy(invoker);
diff --git
a/dubbo-rpc/dubbo-rpc-rmi/src/main/java/com/alibaba/dubbo/rpc/protocol/rmi/RmiRemoteInvocation.java
b/dubbo-rpc/dubbo-rpc-rmi/src/main/java/com/alibaba/dubbo/rpc/protocol/rmi/RmiRemoteInvocation.java
new file mode 100644
index 0000000000..04efd9ea52
--- /dev/null
+++
b/dubbo-rpc/dubbo-rpc-rmi/src/main/java/com/alibaba/dubbo/rpc/protocol/rmi/RmiRemoteInvocation.java
@@ -0,0 +1,35 @@
+/*
+ * 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 com.alibaba.dubbo.rpc.protocol.rmi;
+
+import org.aopalliance.intercept.MethodInvocation;
+
+/**
+ *
+ */
+@Deprecated
+public class RmiRemoteInvocation extends
org.apache.dubbo.rpc.protocol.rmi.RmiRemoteInvocation {
+ private static final long serialVersionUID = 1L;
+ /**
+ * executed on consumer side
+ *
+ * @param methodInvocation
+ */
+ public RmiRemoteInvocation(MethodInvocation methodInvocation) {
+ super(methodInvocation);
+ }
+}
diff --git
a/dubbo-rpc/dubbo-rpc-rmi/src/main/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocol.java
b/dubbo-rpc/dubbo-rpc-rmi/src/main/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocol.java
index 8a28cc02c9..5f8b02afe5 100644
---
a/dubbo-rpc/dubbo-rpc-rmi/src/main/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocol.java
+++
b/dubbo-rpc/dubbo-rpc-rmi/src/main/java/org/apache/dubbo/rpc/protocol/rmi/RmiProtocol.java
@@ -18,7 +18,6 @@
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.Version;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.protocol.AbstractProxyProtocol;
@@ -30,6 +29,9 @@
import java.net.SocketTimeoutException;
import java.rmi.RemoteException;
+import static org.apache.dubbo.common.Version.isFramework263OrHigher;
+import static org.apache.dubbo.common.Version.isFramework270OrHigher;
+
/**
* RmiProtocol.
*/
@@ -74,10 +76,19 @@ public void run() {
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws
RpcException {
final RmiProxyFactoryBean rmiProxyFactoryBean = new
RmiProxyFactoryBean();
- // RMI needs extra parameter since it uses customized remote
invocation object
- if (url.getParameter(Constants.DUBBO_VERSION_KEY,
Version.getProtocolVersion()).equals(Version.getProtocolVersion())) {
- // Check dubbo version on provider, this feature only support
+ /*
+ RMI needs extra parameter since it uses customized remote invocation
object
+
+ The customized RemoteInvocation was firstly introduced in v2.6.3;
The package was renamed to 'org.apache.*'
+ Considering the above two conditions, we need to check before
sending customized RemoteInvocation:
+ 1. if the provider version is v2.7.0 or higher, send
'org.apache.dubbo.rpc.protocol.rmi.RmiRemoteInvocation'.
+ 2. if the provider version is v2.6.3 or higher, send
'com.alibaba.dubbo.rpc.protocol.rmi.RmiRemoteInvocation'.
+ 3. if the provider version is lower than v2.6.3, does not use
customized RemoteInvocation.
+ */
+ if (isFramework270OrHigher(url.getParameter(Constants.RELEASE_KEY))) {
rmiProxyFactoryBean.setRemoteInvocationFactory(RmiRemoteInvocation::new);
+ } else if
(isFramework263OrHigher(url.getParameter(Constants.DUBBO_VERSION_KEY))) {
+
rmiProxyFactoryBean.setRemoteInvocationFactory(com.alibaba.dubbo.rpc.protocol.rmi.RmiRemoteInvocation::new);
}
rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
rmiProxyFactoryBean.setServiceInterface(serviceType);
With regards,
Apache Git Services