SpringStudent commented on code in PR #13155:
URL: https://github.com/apache/dubbo/pull/13155#discussion_r1349825350


##########
dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ReflectionServiceDescriptor.java:
##########
@@ -89,6 +98,21 @@ private void initMethods() {
                     +" stream method signatures. method(" + methodName + ")");
         });
     }
+    
+    public 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();

Review Comment:
   I understand your concern, if I keep the code logic I submitted unchanged, I 
can think some solutions:
   1. Modify the isProtobufClass method, Judge pb class by isAssignableFrom. 
This method requires that the Dubco-common project add the dependency of 
protobuf.
   2. Add cache for isProtobufClass method implementation , Cache the pb class 
while judging the pb class, It can reduce the judgment of the same pb class. In 
addition, I found that the method also be called in the rpc process, By caching 
pb Class,performance of rpc call can be improved by caching pb class also.
   3. Adding caching in mode 1 has the same benefits as in mode 2



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to