This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0-multi-instances
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0-multi-instances by this
push:
new 598c99c Fix ServiceModel cast error
598c99c is described below
commit 598c99cc78adb151a2e387fe6a68db42ce9619eb
Author: Albumen Kevin <[email protected]>
AuthorDate: Mon Aug 30 12:52:46 2021 +0800
Fix ServiceModel cast error
---
.../apache/dubbo/rpc/proxy/InvokerInvocationHandler.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/InvokerInvocationHandler.java
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/InvokerInvocationHandler.java
index ca02f6b..70e8b83 100644
---
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/InvokerInvocationHandler.java
+++
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/InvokerInvocationHandler.java
@@ -24,6 +24,7 @@ import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcInvocation;
import org.apache.dubbo.rpc.RpcServiceContext;
import org.apache.dubbo.rpc.model.ConsumerModel;
+import org.apache.dubbo.rpc.model.ServiceModel;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
@@ -35,7 +36,7 @@ import java.lang.reflect.Method;
public class InvokerInvocationHandler implements InvocationHandler {
private static final Logger logger =
LoggerFactory.getLogger(InvokerInvocationHandler.class);
private final Invoker<?> invoker;
- private ConsumerModel consumerModel;
+ private ServiceModel serviceModel;
private URL url;
private String protocolServiceKey;
@@ -54,7 +55,7 @@ public class InvokerInvocationHandler implements
InvocationHandler {
this.invoker = handler;
this.url = invoker.getUrl();
this.protocolServiceKey = this.url.getProtocolServiceKey();
- this.consumerModel = (ConsumerModel) this.url.getServiceModel();
+ this.serviceModel = this.url.getServiceModel();
}
@Override
@@ -76,16 +77,16 @@ public class InvokerInvocationHandler implements
InvocationHandler {
} else if (parameterTypes.length == 1 && "equals".equals(methodName)) {
return invoker.equals(args[0]);
}
- RpcInvocation rpcInvocation = new RpcInvocation(consumerModel, method,
invoker.getInterface().getName(), protocolServiceKey, args);
+ RpcInvocation rpcInvocation = new RpcInvocation(serviceModel, method,
invoker.getInterface().getName(), protocolServiceKey, args);
String serviceKey = url.getServiceKey();
rpcInvocation.setTargetServiceUniqueName(serviceKey);
// invoker.getUrl() returns consumer url.
RpcServiceContext.setRpcContext(url);
- if (consumerModel != null) {
- rpcInvocation.put(Constants.CONSUMER_MODEL, consumerModel);
- rpcInvocation.put(Constants.METHOD_MODEL,
consumerModel.getMethodModel(method));
+ if (serviceModel instanceof ConsumerModel) {
+ rpcInvocation.put(Constants.CONSUMER_MODEL, serviceModel);
+ rpcInvocation.put(Constants.METHOD_MODEL, ((ConsumerModel)
serviceModel).getMethodModel(method));
}
return invoker.invoke(rpcInvocation).recreate();