Skip to content

Commit f6885ed

Browse files
committed
Fix:triple protocol echoService invoke.
1 parent 652a78a commit f6885ed

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

dubbo-rpc/dubbo-rpc-triple/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
<artifactId>reactor-core</artifactId>
8686
<scope>test</scope>
8787
</dependency>
88+
<dependency>
89+
<groupId>org.apache.dubbo</groupId>
90+
<artifactId>dubbo-cluster</artifactId>
91+
<version>${project.parent.version}</version>
92+
<scope>test</scope>
93+
</dependency>
8894
</dependencies>
8995
<build>
9096
<plugins>

dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,17 @@ protected Result doInvoke(final Invocation invocation) {
144144
ServiceDescriptor serviceDescriptor = consumerModel.getServiceModel();
145145
MethodDescriptor methodDescriptor =
146146
serviceDescriptor.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
147-
if (methodDescriptor == null
148-
&& RpcUtils.isGenericCall(
149-
((RpcInvocation) invocation).getParameterTypesDesc(), invocation.getMethodName())) {
150-
// Only reach when server generic
151-
methodDescriptor = ServiceDescriptorInternalCache.genericService()
152-
.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
147+
if (methodDescriptor == null) {
148+
if (RpcUtils.isGenericCall(
149+
((RpcInvocation) invocation).getParameterTypesDesc(), invocation.getMethodName())) {
150+
// Only reach when server generic
151+
methodDescriptor = ServiceDescriptorInternalCache.genericService()
152+
.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
153+
} else if (RpcUtils.isEcho(
154+
((RpcInvocation) invocation).getParameterTypesDesc(), invocation.getMethodName())) {
155+
methodDescriptor = ServiceDescriptorInternalCache.echoService()
156+
.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
157+
}
153158
}
154159
ExecutorService callbackExecutor =
155160
isSync(methodDescriptor, invocation) ? new ThreadlessExecutor() : streamExecutor;

dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocolTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.dubbo.rpc.protocol.tri;
1818

1919
import org.apache.dubbo.common.URL;
20+
import org.apache.dubbo.common.extension.ExtensionLoader;
2021
import org.apache.dubbo.common.stream.StreamObserver;
2122
import org.apache.dubbo.common.utils.ClassUtils;
2223
import org.apache.dubbo.common.utils.NetUtils;
@@ -33,13 +34,15 @@
3334
import org.apache.dubbo.rpc.protocol.tri.support.IGreeter;
3435
import org.apache.dubbo.rpc.protocol.tri.support.IGreeterImpl;
3536
import org.apache.dubbo.rpc.protocol.tri.support.MockStreamObserver;
37+
import org.apache.dubbo.rpc.service.EchoService;
3638

3739
import java.util.concurrent.TimeUnit;
3840

3941
import org.junit.jupiter.api.Assertions;
4042
import org.junit.jupiter.api.Test;
4143

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

4447
class TripleProtocolTest {
4548

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

68-
Protocol protocol = new TripleProtocol(providerUrl.getOrDefaultFrameworkModel());
71+
Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getExtension("tri");
72+
6973
ProxyFactory proxy =
7074
applicationModel.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
7175
Invoker<IGreeter> invoker = proxy.getInvoker(serviceImpl, IGreeter.class, providerUrl);
@@ -107,6 +111,11 @@ void testDemoProtocol() throws Exception {
107111
Assertions.assertEquals(REQUEST_MSG, serverOutboundMessageSubscriber.getOnNextData());
108112
Assertions.assertTrue(serverOutboundMessageSubscriber.isOnCompleted());
109113

114+
EchoService echo = proxy.getProxy(protocol.refer(EchoService.class, consumerUrl));
115+
assertEquals(echo.$echo("test"), "test");
116+
assertEquals(echo.$echo("abcdefg"), "abcdefg");
117+
assertEquals(echo.$echo(1234), 1234);
118+
110119
export.unexport();
111120
protocol.destroy();
112121
// resource recycle.

0 commit comments

Comments
 (0)