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 416374cd78 Protobuf method not allow override (#13155)
416374cd78 is described below
commit 416374cd78f87fc20d293e4f2af6e6ef452b198d
Author: 宝宝爸师 <[email protected]>
AuthorDate: Thu Oct 19 12:31:59 2023 +0800
Protobuf method not allow override (#13155)
* pb method not allow override
* pb method not allow override
* remove wildcard import
* if judgement split into 2 simple
* add pb method override ut&it
* modify pb method override exception msg
* update pb method override test case
* format code
* format code
* optimize import
* Optimize the isProtobufClass method
* fix sonarLint problems
* fix sonar problem
* use ProtobufUtils.class ClassLoader to load Protobuf Message
* format code
* protobufUtils add log
---------
Co-authored-by: Albumen Kevin <[email protected]>
Co-authored-by: earthchen <[email protected]>
---
dubbo-common/pom.xml | 5 +++
.../apache/dubbo/common/utils/ProtobufUtils.java | 47 +++++++++++++++++++++
.../rpc/model/ReflectionServiceDescriptor.java | 12 +++++-
.../org/apache/dubbo/common/ProtobufUtilsTest.java | 39 +++++++++++++++++
.../org/apache/dubbo/rpc/model/HelloReply.java | 49 ++++++++++++++++++++++
.../org/apache/dubbo/rpc/model/HelloRequest.java | 49 ++++++++++++++++++++++
.../rpc/model/ReflectionServiceDescriptorTest.java | 16 +++++++
.../org/apache/dubbo/rpc/support/DemoService2.java | 24 +++++++++++
.../apache/dubbo/rpc/support/DemoService2Impl.java | 29 +++++++++++++
.../org/apache/dubbo/rpc/support/DemoService3.java | 27 ++++++++++++
.../apache/dubbo/rpc/support/DemoService3Impl.java | 32 ++++++++++++++
.../rpc/protocol/tri/ReflectionPackableMethod.java | 23 ++--------
.../dubbo/rpc/protocol/tri/TripleProtocolTest.java | 6 ++-
.../dubbo/rpc/protocol/tri/support/IGreeter.java | 4 ++
.../rpc/protocol/tri/support/IGreeterImpl.java | 10 +++++
15 files changed, 350 insertions(+), 22 deletions(-)
diff --git a/dubbo-common/pom.xml b/dubbo-common/pom.xml
index d9413ee7ad..d70714824a 100644
--- a/dubbo-common/pom.xml
+++ b/dubbo-common/pom.xml
@@ -100,5 +100,10 @@
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ProtobufUtils.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ProtobufUtils.java
new file mode 100644
index 0000000000..458a8ad222
--- /dev/null
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ProtobufUtils.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.common.utils;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+
+import static
org.apache.dubbo.common.constants.CommonConstants.PROTOBUF_MESSAGE_CLASS_NAME;
+
+public class ProtobufUtils {
+
+ private static final Logger logger =
LoggerFactory.getLogger(ProtobufUtils.class);
+
+ private static Class<?> protobufClss;
+
+ private ProtobufUtils() {
+ }
+
+ static {
+ try {
+ protobufClss = ClassUtils.forName(PROTOBUF_MESSAGE_CLASS_NAME,
ProtobufUtils.class.getClassLoader());
+ } catch (Throwable t) {
+ logger.info("protobuf's dependency is absent");
+ }
+ }
+
+ public static boolean isProtobufClass(Class<?> pojoClazz) {
+ if (protobufClss != null) {
+ return protobufClss.isAssignableFrom(pojoClazz);
+ }
+ return false;
+ }
+}
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptor.java
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptor.java
index 489f7e4c6c..9983bdae91 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptor.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptor.java
@@ -18,6 +18,7 @@
package org.apache.dubbo.rpc.model;
import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.common.utils.ProtobufUtils;
import org.apache.dubbo.metadata.definition.ServiceDefinitionBuilder;
import org.apache.dubbo.metadata.definition.model.FullServiceDefinition;
@@ -74,11 +75,18 @@ public class ReflectionServiceDescriptor implements
ServiceDescriptor {
}
methods.forEach((methodName, methodList) -> {
+ //pb method not allow override
+ if (methodList.size() > 1) {
+ long pbMethodCount =
methodList.stream().filter(methodDescriptor ->
Arrays.stream(methodDescriptor.getParameterClasses()).anyMatch(ProtobufUtils::isProtobufClass)).count();
+ if (pbMethodCount > 0L) {
+ throw new IllegalStateException("Protobuf method not allow
override," + "method(" + interfaceName + "." + methodName + ").");
+ }
+ }
Map<String, MethodDescriptor> descMap =
descToMethods.computeIfAbsent(methodName, k -> new HashMap<>());
// not support BI_STREAM and SERVER_STREAM at the same time, for
example,
// void foo(Request, StreamObserver<Response>) ---> SERVER_STREAM
// StreamObserver<Response> foo(StreamObserver<Request>) --->
BI_STREAM
- long streamMethodCount = methodList.stream()
+ long streamMethodCount = methodList.stream()
.peek(methodModel -> descMap.put(methodModel.getParamDesc(),
methodModel))
.map(MethodDescriptor::getRpcType)
.filter(rpcType -> rpcType ==
MethodDescriptor.RpcType.SERVER_STREAM
@@ -86,7 +94,7 @@ public class ReflectionServiceDescriptor implements
ServiceDescriptor {
.count();
if (streamMethodCount > 1L)
throw new IllegalStateException("Stream method could not be
overloaded.There are " + streamMethodCount
- +" stream method signatures. method(" + methodName + ")");
+ + " stream method signatures. method(" + methodName + ")");
});
}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/common/ProtobufUtilsTest.java
b/dubbo-common/src/test/java/org/apache/dubbo/common/ProtobufUtilsTest.java
new file mode 100644
index 0000000000..41bed2e928
--- /dev/null
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/ProtobufUtilsTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.common;
+
+import org.apache.dubbo.common.utils.ProtobufUtils;
+import org.apache.dubbo.common.vo.UserVo;
+import org.apache.dubbo.rpc.model.HelloReply;
+import org.apache.dubbo.rpc.model.HelloRequest;
+import org.apache.dubbo.rpc.model.Person;
+import org.apache.dubbo.rpc.model.SerializablePerson;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class ProtobufUtilsTest {
+
+ @Test
+ void testIsProtobufClass() {
+
Assertions.assertTrue(ProtobufUtils.isProtobufClass(HelloRequest.class));
+ Assertions.assertTrue(ProtobufUtils.isProtobufClass(HelloReply.class));
+ Assertions.assertFalse(ProtobufUtils.isProtobufClass(Person.class));
+
Assertions.assertFalse(ProtobufUtils.isProtobufClass(SerializablePerson.class));
+ Assertions.assertFalse(ProtobufUtils.isProtobufClass(UserVo.class));
+ }
+}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/HelloReply.java
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/HelloReply.java
new file mode 100644
index 0000000000..e7b56e66bc
--- /dev/null
+++ b/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/HelloReply.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.dubbo.rpc.model;
+
+import com.google.protobuf.Message;
+
+public final class HelloReply extends com.google.protobuf.GeneratedMessageV3 {
+
+ @Override
+ protected FieldAccessorTable internalGetFieldAccessorTable() {
+ return null;
+ }
+
+ @Override
+ protected Message.Builder newBuilderForType(BuilderParent builderParent) {
+ return null;
+ }
+
+ @Override
+ public Message.Builder newBuilderForType() {
+ return null;
+ }
+
+ @Override
+ public Message.Builder toBuilder() {
+ return null;
+ }
+
+ @Override
+ public Message getDefaultInstanceForType() {
+ return null;
+ }
+}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/HelloRequest.java
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/HelloRequest.java
new file mode 100644
index 0000000000..dacf17d159
--- /dev/null
+++ b/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/HelloRequest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.dubbo.rpc.model;
+
+import com.google.protobuf.Message;
+
+public final class HelloRequest extends com.google.protobuf.GeneratedMessageV3
{
+
+ @Override
+ protected FieldAccessorTable internalGetFieldAccessorTable() {
+ return null;
+ }
+
+ @Override
+ protected Message.Builder newBuilderForType(BuilderParent builderParent) {
+ return null;
+ }
+
+ @Override
+ public Message.Builder newBuilderForType() {
+ return null;
+ }
+
+ @Override
+ public Message.Builder toBuilder() {
+ return null;
+ }
+
+ @Override
+ public Message getDefaultInstanceForType() {
+ return null;
+ }
+}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptorTest.java
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptorTest.java
index b7011526be..3b0ccfbc3a 100644
---
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptorTest.java
+++
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptorTest.java
@@ -22,6 +22,9 @@ import
org.apache.dubbo.metadata.definition.TypeDefinitionBuilder;
import org.apache.dubbo.rpc.support.DemoService;
import org.apache.dubbo.rpc.support.DemoService1;
+import org.apache.dubbo.rpc.support.DemoService2;
+import org.apache.dubbo.rpc.support.DemoService3;
+
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -107,4 +110,17 @@ class ReflectionServiceDescriptorTest {
DemoService.class);
Assertions.assertEquals(service2.hashCode(), service3.hashCode());
}
+
+ @Test
+ void testPbMethodOverride() {
+ new ReflectionServiceDescriptor(DemoService.class);
+ new ReflectionServiceDescriptor(DemoService2.class);
+ String EXPECT_RESPONSE_MSG = "Protobuf method not allow
override,method(org.apache.dubbo.rpc.support.DemoService3.sayHello).";
+ try {
+ new ReflectionServiceDescriptor(DemoService3.class);
+ } catch (IllegalStateException e) {
+ Assertions.assertEquals(EXPECT_RESPONSE_MSG, e.getMessage());
+ }
+
+ }
}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService2.java
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService2.java
new file mode 100644
index 0000000000..66642fec34
--- /dev/null
+++ b/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService2.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc.support;
+
+public interface DemoService2 {
+
+ String sayHello(String name);
+
+ Integer sayHello(Integer num);
+}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService2Impl.java
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService2Impl.java
new file mode 100644
index 0000000000..91853306a0
--- /dev/null
+++
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService2Impl.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc.support;
+
+public class DemoService2Impl implements DemoService2 {
+ @Override
+ public String sayHello(String name) {
+ return name;
+ }
+
+ @Override
+ public Integer sayHello(Integer num) {
+ return num;
+ }
+}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService3.java
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService3.java
new file mode 100644
index 0000000000..6a6981a6c0
--- /dev/null
+++ b/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService3.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc.support;
+
+import org.apache.dubbo.rpc.model.HelloReply;
+import org.apache.dubbo.rpc.model.HelloRequest;
+
+public interface DemoService3 {
+
+ HelloReply sayHello(HelloRequest request);
+
+ Integer sayHello(Integer num);
+}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService3Impl.java
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService3Impl.java
new file mode 100644
index 0000000000..37ecebebc2
--- /dev/null
+++
b/dubbo-common/src/test/java/org/apache/dubbo/rpc/support/DemoService3Impl.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc.support;
+
+import org.apache.dubbo.rpc.model.HelloReply;
+import org.apache.dubbo.rpc.model.HelloRequest;
+
+public class DemoService3Impl implements DemoService3 {
+ @Override
+ public HelloReply sayHello(HelloRequest request) {
+ return null;
+ }
+
+ @Override
+ public Integer sayHello(Integer num) {
+ return null;
+ }
+}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java
index 66f34d48c3..3a0486cb1c 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java
@@ -21,6 +21,7 @@ import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.serialize.MultipleSerialization;
import org.apache.dubbo.common.stream.StreamObserver;
+import org.apache.dubbo.common.utils.ProtobufUtils;
import org.apache.dubbo.config.Constants;
import org.apache.dubbo.remoting.transport.CodecSupport;
import org.apache.dubbo.remoting.utils.UrlUtils;
@@ -41,7 +42,6 @@ import java.util.Iterator;
import java.util.stream.Stream;
import static org.apache.dubbo.common.constants.CommonConstants.$ECHO;
-import static
org.apache.dubbo.common.constants.CommonConstants.PROTOBUF_MESSAGE_CLASS_NAME;
public class ReflectionPackableMethod implements PackableMethod {
@@ -145,7 +145,7 @@ public class ReflectionPackableMethod implements
PackableMethod {
if ($ECHO.equals(methodName)) {
return true;
}
- boolean returnClassProtobuf = isProtobufClass(returnClass);
+ boolean returnClassProtobuf =
ProtobufUtils.isProtobufClass(returnClass);
// Response foo()
if (parameterClasses.length == 0) {
return !returnClassProtobuf;
@@ -157,7 +157,7 @@ public class ReflectionPackableMethod implements
PackableMethod {
// count normal and protobuf param
for (int i = 0; i < parameterClasses.length; i++) {
Class<?> parameterClass = parameterClasses[i];
- if (isProtobufClass(parameterClass)) {
+ if (ProtobufUtils.isProtobufClass(parameterClass)) {
protobufParameterCount++;
} else {
if (isStreamType(parameterClass)) {
@@ -239,7 +239,7 @@ public class ReflectionPackableMethod implements
PackableMethod {
if
(TRI_ASYNC_RETURN_CLASS.equalsIgnoreCase(returnClass.getName())) {
Class<?> actualReturnClass = (Class<?>) ((ParameterizedType)
methodDescriptor.getMethod()
.getGenericReturnType()).getActualTypeArguments()[0];
- boolean actualReturnClassProtobuf =
isProtobufClass(actualReturnClass);
+ boolean actualReturnClassProtobuf =
ProtobufUtils.isProtobufClass(actualReturnClass);
if (actualReturnClassProtobuf && protobufParameterCount == 1) {
return false;
}
@@ -273,21 +273,6 @@ public class ReflectionPackableMethod implements
PackableMethod {
return RX_RETURN_CLASS.equalsIgnoreCase(clz.getName());
}
- static boolean isProtobufClass(Class<?> clazz) {
- while (clazz != Object.class && clazz != null) {
- Class<?>[] interfaces = clazz.getInterfaces();
- if (interfaces.length > 0) {
- for (Class<?> clazzInterface : interfaces) {
- if
(PROTOBUF_MESSAGE_CLASS_NAME.equalsIgnoreCase(clazzInterface.getName())) {
- return true;
- }
- }
- }
- clazz = clazz.getSuperclass();
- }
- return false;
- }
-
private static String convertHessianFromWrapper(String serializeType) {
if (TripleConstant.HESSIAN4.equals(serializeType)) {
return TripleConstant.HESSIAN2;
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocolTest.java
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocolTest.java
index 483897d971..a5961ebb36 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocolTest.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocolTest.java
@@ -34,7 +34,6 @@ import org.apache.dubbo.rpc.model.ServiceMetadata;
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.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -85,7 +84,10 @@ class TripleProtocolTest {
// 1. test unaryStream
String REQUEST_MSG = "hello world";
+ Integer REQUEST_INT = 1024;
+ greeterProxy.echo();
Assertions.assertEquals(REQUEST_MSG, greeterProxy.echo(REQUEST_MSG));
+ Assertions.assertEquals(REQUEST_INT, greeterProxy.echo(REQUEST_INT));
Assertions.assertEquals(REQUEST_MSG,
serviceImpl.echoAsync(REQUEST_MSG).get());
// 2. test serverStream
@@ -117,4 +119,6 @@ class TripleProtocolTest {
serviceRepository.destroy();
System.out.println("serviceRepository destroyed");
}
+
+
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/support/IGreeter.java
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/support/IGreeter.java
index 42a89af743..eb0f23e1b2 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/support/IGreeter.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/support/IGreeter.java
@@ -30,6 +30,10 @@ public interface IGreeter {
*/
String echo(String request);
+ Integer echo(Integer request);
+
+ void echo();
+
default CompletableFuture<String> echoAsync(String request) {
return CompletableFuture.supplyAsync(() -> echo(request));
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/support/IGreeterImpl.java
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/support/IGreeterImpl.java
index f0b54fa1c6..0e58423d28 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/support/IGreeterImpl.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/support/IGreeterImpl.java
@@ -28,6 +28,16 @@ public class IGreeterImpl implements IGreeter {
return request;
}
+ @Override
+ public Integer echo(Integer request) {
+ return request;
+ }
+
+ @Override
+ public void echo() {
+ System.out.println("echo() invoke");
+ }
+
@Override
public void serverStream(String str, StreamObserver<String> observer) {
System.out.println("server stream data=" + str);