From aa9214da41d92db70bc052105472507b19d531e1 Mon Sep 17 00:00:00 2001 From: foghost Date: Sun, 17 Mar 2024 23:03:58 +0800 Subject: [PATCH] fix async method call ClassCastException error --- .../registry/client/ServiceDiscoveryRegistryDirectory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java index 224b2240227..b743a1c30ef 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java @@ -778,6 +778,12 @@ public Result invoke(Invocation invocation) throws RpcException { invocation instanceof RpcInvocation ? ((RpcInvocation) invocation).getInvokeMode() : null); copiedInvocation.setObjectAttachment(CommonConstants.GROUP_KEY, protocolServiceKey.getGroup()); copiedInvocation.setObjectAttachment(CommonConstants.VERSION_KEY, protocolServiceKey.getVersion()); + // When there are multiple MethodDescriptors with the same method name, the return type will be wrong + // same with org.apache.dubbo.rpc.stub.StubInvocationUtil.call + // fix https://github.com/apache/dubbo/issues/13931 + if (invocation instanceof RpcInvocation) { + copiedInvocation.setReturnType(((RpcInvocation) invocation).getReturnType()); + } return originInvoker.invoke(copiedInvocation); }