This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new a4e9c9efa4 Fix local invoke consumer url override (#12553)
a4e9c9efa4 is described below
commit a4e9c9efa4ec79ca6e371141762c3da84718c65f
Author: Albumen Kevin <[email protected]>
AuthorDate: Mon Jun 19 09:34:29 2023 +0800
Fix local invoke consumer url override (#12553)
---
.../rpc/cluster/support/wrapper/ScopeClusterInvoker.java | 14 ++++++++++----
.../org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java | 2 +-
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/ScopeClusterInvoker.java
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/ScopeClusterInvoker.java
index a0564c9b0a..98fd33bfef 100644
---
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/ScopeClusterInvoker.java
+++
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/ScopeClusterInvoker.java
@@ -20,6 +20,7 @@ package org.apache.dubbo.rpc.cluster.support.wrapper;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.url.component.DubboServiceAddressURL;
import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.rpc.Exporter;
@@ -179,7 +180,7 @@ public class ScopeClusterInvoker<T> implements
ClusterInvoker<T>, ExporterChange
}
if
(getUrl().getServiceKey().equals(exporter.getInvoker().getUrl().getServiceKey())
&&
exporter.getInvoker().getUrl().getProtocol().equalsIgnoreCase(LOCAL_PROTOCOL)) {
- createInjvmInvoker();
+ createInjvmInvoker(exporter);
isExported.compareAndSet(false, true);
}
}
@@ -275,14 +276,19 @@ public class ScopeClusterInvoker<T> implements
ClusterInvoker<T>, ExporterChange
/**
* Creates a new Invoker for the current ScopeClusterInvoker and exports
it to the local JVM.
*/
- private void createInjvmInvoker() {
+ private void createInjvmInvoker(Exporter<?> exporter) {
if (injvmInvoker == null) {
synchronized (createLock) {
if (injvmInvoker == null) {
- URL url = new ServiceConfigURL(LOCAL_PROTOCOL,
NetUtils.getLocalHost(), getUrl().getPort(), getInterface().getName(),
getUrl().getParameters());
+ URL url = new ServiceConfigURL(LOCAL_PROTOCOL,
NetUtils.getLocalHost(), getUrl().getPort(),
+ getInterface().getName(), getUrl().getParameters());
url = url.setScopeModel(getUrl().getScopeModel());
url = url.setServiceModel(getUrl().getServiceModel());
- Invoker<?> invoker = protocolSPI.refer(getInterface(),
url);
+
+ DubboServiceAddressURL consumerUrl = new
DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(),
+ exporter.getInvoker().getUrl(), null);
+
+ Invoker<?> invoker = protocolSPI.refer(getInterface(),
consumerUrl);
List<Invoker<?>> invokers = new ArrayList<>();
invokers.add(invoker);
injvmInvoker = Cluster.getCluster(url.getScopeModel(),
Cluster.DEFAULT, false).join(new StaticDirectory(url, invokers), true);
diff --git
a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java
b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java
index 7e3a1d11fb..971b4f7402 100644
---
a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java
+++
b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java
@@ -229,7 +229,7 @@ public class InjvmInvoker<T> extends AbstractInvoker<T> {
if (pts != null && args != null && pts.length == args.length) {
realArgument = new Object[pts.length];
for (int i = 0; i < pts.length; i++) {
- realArgument[i] =
paramDeepCopyUtil.copy(invoker.getUrl(), args[i], pts[i]);
+ realArgument[i] = paramDeepCopyUtil.copy(getUrl(),
args[i], pts[i]);
}
}
if (realArgument == null) {