This is an automated email from the ASF dual-hosted git repository.
earthchen 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 90325f2fe6 fix triple npe (#12918)
90325f2fe6 is described below
commit 90325f2fe63dd17d17aea2a15cfb644aa31fa8df
Author: icodening <[email protected]>
AuthorDate: Thu Aug 17 13:19:08 2023 +0800
fix triple npe (#12918)
---
.../dubbo/rpc/protocol/tri/TripleInvoker.java | 23 ++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java
index c5ba56b1db..61c6870c50 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java
@@ -25,6 +25,7 @@ import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.common.threadpool.ThreadlessExecutor;
+import org.apache.dubbo.common.utils.ReflectUtils;
import org.apache.dubbo.remoting.api.connection.AbstractConnectionClient;
import org.apache.dubbo.rpc.AppResponse;
import org.apache.dubbo.rpc.AsyncRpcResult;
@@ -55,6 +56,7 @@ import
org.apache.dubbo.rpc.protocol.tri.compressor.Compressor;
import org.apache.dubbo.rpc.protocol.tri.compressor.Identity;
import org.apache.dubbo.rpc.protocol.tri.observer.ClientCallToObserverAdapter;
import org.apache.dubbo.rpc.protocol.tri.transport.TripleWriteQueue;
+import org.apache.dubbo.rpc.service.ServiceDescriptorInternalCache;
import org.apache.dubbo.rpc.support.RpcUtils;
import io.netty.util.AsciiString;
@@ -65,6 +67,7 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.stream.Collectors;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY;
import static
org.apache.dubbo.common.constants.CommonConstants.DUBBO_PACKABLE_METHOD_FACTORY;
@@ -131,9 +134,13 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
ConsumerModel consumerModel = (ConsumerModel)
(invocation.getServiceModel() != null
? invocation.getServiceModel() : getUrl().getServiceModel());
ServiceDescriptor serviceDescriptor = consumerModel.getServiceModel();
- final MethodDescriptor methodDescriptor = serviceDescriptor.getMethod(
- invocation.getMethodName(),
- invocation.getParameterTypes());
+ final MethodDescriptor methodDescriptor;
+ boolean genericCall =
RpcUtils.isGenericCall(ReflectUtils.getDesc(invocation.getParameterTypes()),
invocation.getMethodName());
+ if (!genericCall) {
+ methodDescriptor =
serviceDescriptor.getMethod(invocation.getMethodName(),
invocation.getParameterTypes());
+ } else {
+ methodDescriptor =
ServiceDescriptorInternalCache.genericService().getMethod(invocation.getMethodName(),
invocation.getParameterTypes());
+ }
ExecutorService callbackExecutor = isSync(methodDescriptor,
invocation) ? new ThreadlessExecutor() : streamExecutor;
ClientCall call = new TripleClientCall(connectionClient,
callbackExecutor,
getUrl().getOrDefaultFrameworkModel(), writeQueue);
@@ -239,7 +246,15 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
if (methodDescriptor instanceof StubMethodDescriptor) {
pureArgument = invocation.getArguments()[0];
} else {
- pureArgument = invocation.getArguments();
+ if (methodDescriptor.isGeneric()) {
+ Object[] args = new Object[3];
+ args[0] = RpcUtils.getMethodName(invocation);
+ args[1] =
Arrays.stream(RpcUtils.getParameterTypes(invocation)).map(Class::getName).collect(Collectors.toList());
+ args[2] = RpcUtils.getArguments(invocation);
+ pureArgument = args;
+ } else {
+ pureArgument = invocation.getArguments();
+ }
}
result = new AsyncRpcResult(future, invocation);
if (setFutureWhenSync || ((RpcInvocation) invocation).getInvokeMode()
!= InvokeMode.SYNC) {