Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix:triple protocol echoService invoke.
  • Loading branch information
wuwen5 committed Feb 13, 2025
commit f6885ed3088e7f862b9a7bff7b34d10871915902
6 changes: 6 additions & 0 deletions dubbo-rpc/dubbo-rpc-triple/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
<artifactId>reactor-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-cluster</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,17 @@ protected Result doInvoke(final Invocation invocation) {
ServiceDescriptor serviceDescriptor = consumerModel.getServiceModel();
MethodDescriptor methodDescriptor =
serviceDescriptor.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
if (methodDescriptor == null
&& RpcUtils.isGenericCall(
((RpcInvocation) invocation).getParameterTypesDesc(), invocation.getMethodName())) {
// Only reach when server generic
methodDescriptor = ServiceDescriptorInternalCache.genericService()
.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
if (methodDescriptor == null) {
if (RpcUtils.isGenericCall(
((RpcInvocation) invocation).getParameterTypesDesc(), invocation.getMethodName())) {
// Only reach when server generic
methodDescriptor = ServiceDescriptorInternalCache.genericService()
.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
} else if (RpcUtils.isEcho(
((RpcInvocation) invocation).getParameterTypesDesc(), invocation.getMethodName())) {
methodDescriptor = ServiceDescriptorInternalCache.echoService()
.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
}
}
ExecutorService callbackExecutor =
isSync(methodDescriptor, invocation) ? new ThreadlessExecutor() : streamExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.NetUtils;
Expand All @@ -33,13 +34,15 @@
import org.apache.dubbo.rpc.protocol.tri.support.IGreeter;
import org.apache.dubbo.rpc.protocol.tri.support.IGreeterImpl;
import org.apache.dubbo.rpc.protocol.tri.support.MockStreamObserver;
import org.apache.dubbo.rpc.service.EchoService;

import java.util.concurrent.TimeUnit;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.apache.dubbo.rpc.protocol.tri.support.IGreeter.SERVER_MSG;
import static org.junit.jupiter.api.Assertions.assertEquals;

class TripleProtocolTest {

Expand All @@ -65,7 +68,8 @@ void testDemoProtocol() throws Exception {
serviceRepository.registerProvider(providerModel);
providerUrl = providerUrl.setServiceModel(providerModel);

Protocol protocol = new TripleProtocol(providerUrl.getOrDefaultFrameworkModel());
Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getExtension("tri");

ProxyFactory proxy =
applicationModel.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Invoker<IGreeter> invoker = proxy.getInvoker(serviceImpl, IGreeter.class, providerUrl);
Expand Down Expand Up @@ -107,6 +111,11 @@ void testDemoProtocol() throws Exception {
Assertions.assertEquals(REQUEST_MSG, serverOutboundMessageSubscriber.getOnNextData());
Assertions.assertTrue(serverOutboundMessageSubscriber.isOnCompleted());

EchoService echo = proxy.getProxy(protocol.refer(EchoService.class, consumerUrl));
assertEquals(echo.$echo("test"), "test");
assertEquals(echo.$echo("abcdefg"), "abcdefg");
assertEquals(echo.$echo(1234), 1234);

export.unexport();
protocol.destroy();
// resource recycle.
Expand Down