This is an automated email from the ASF dual-hosted git repository.
vongosling pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-spring.git
The following commit(s) were added to refs/heads/master by this push:
new 054d3e5 [ISSUE #151] Fix the Infinite loop in
DefaultRocketMQListenerContainer
new a86b8ef Merge pull request #206 from zhangjidi2016/master
054d3e5 is described below
commit 054d3e51ab45b89951453d2e0dcfea74b74ed5f8
Author: zhangjidi <[email protected]>
AuthorDate: Thu Dec 19 17:39:31 2019 +0800
[ISSUE #151] Fix the Infinite loop in DefaultRocketMQListenerContainer
---
.../support/DefaultRocketMQListenerContainer.java | 40 +++++++++++-----------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git
a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java
b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java
index ad59bc9..691e516 100644
---
a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java
+++
b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java
@@ -425,33 +425,33 @@ public class DefaultRocketMQListenerContainer implements
InitializingBean,
private Type getMessageType() {
Class<?> targetClass =
AopProxyUtils.ultimateTargetClass(rocketMQListener);
- Type[] interfaces = targetClass.getGenericInterfaces();
- Class<?> superclass = targetClass.getSuperclass();
- while ((Objects.isNull(interfaces) || 0 == interfaces.length) &&
Objects.nonNull(superclass)) {
- interfaces = superclass.getGenericInterfaces();
- superclass = targetClass.getSuperclass();
- }
- if (Objects.nonNull(interfaces)) {
- for (Type type : interfaces) {
- if (type instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType)
type;
- if (Objects.equals(parameterizedType.getRawType(),
RocketMQListener.class)) {
- Type[] actualTypeArguments =
parameterizedType.getActualTypeArguments();
- if (Objects.nonNull(actualTypeArguments) &&
actualTypeArguments.length > 0) {
- return actualTypeArguments[0];
- } else {
- return Object.class;
- }
+ Type matchedGenericInterface = null;
+ while (Objects.nonNull(targetClass)) {
+ Type[] interfaces = targetClass.getGenericInterfaces();
+ if (Objects.nonNull(interfaces)) {
+ for (Type type : interfaces) {
+ if (type instanceof ParameterizedType
+ && Objects.equals(((ParameterizedType)
type).getRawType(), RocketMQListener.class)) {
+ matchedGenericInterface = type;
+ break;
}
}
}
-
- return Object.class;
- } else {
+ targetClass = targetClass.getSuperclass();
+ }
+ if (Objects.isNull(matchedGenericInterface)) {
return Object.class;
}
+
+ Type[] actualTypeArguments = ((ParameterizedType)
matchedGenericInterface).getActualTypeArguments();
+ if (Objects.nonNull(actualTypeArguments) && actualTypeArguments.length
> 0) {
+ return actualTypeArguments[0];
+ }
+ return Object.class;
}
+
+
private void initRocketMQPushConsumer() throws MQClientException {
Assert.notNull(rocketMQListener, "Property 'rocketMQListener' is
required");
Assert.notNull(consumerGroup, "Property 'consumerGroup' is required");