You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/09/29 03:36:38 UTC

[GitHub] [rocketmq-spring] shepherdviolet opened a new issue #151: BUG: Infinite loop in DefaultRocketMQListenerContainer

shepherdviolet opened a new issue #151: BUG: Infinite loop in DefaultRocketMQListenerContainer
URL: https://github.com/apache/rocketmq-spring/issues/151
 
 
   https://github.com/apache/rocketmq-spring/blob/908ea4812192b36789c46d230b2fa61f51f3c867/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java#L392-L395
   
   If there is more than one inheritance from RocketMQListener, there will be an infinite loop. For example, MyRocketMQListener --extend--> BaseRocketMQListener --extend--> AbstractRocketMQListener --implement--> RocketMQListener.
   
   Suggestion: Adjust the method getMessageType. 
   
   Our way to get actual type of generic:
   
   ```text
       private static Type[] getGenericTypesOfInterface(Class clazz, Class targetGenericInterface) {
           Type matchedGenericInterface = null;
           while (clazz != null) {
               Type[] genericInterfaces = clazz.getGenericInterfaces();
               if (genericInterfaces != null) {
                   for (Type genericInterface : genericInterfaces) {
                       if (genericInterface instanceof ParameterizedType && targetGenericInterface.equals(((ParameterizedType) genericInterface).getRawType())) {
                           matchedGenericInterface = genericInterface;
                           break;
                       }
                   }
               }
               clazz = clazz.getSuperclass();
           }
           if (matchedGenericInterface == null) {
               return null;
           }
           return ((ParameterizedType) matchedGenericInterface).getActualTypeArguments();
       }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services