Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Infinite loop in DefaultRocketMQListenerContainer #151

Closed
shepherdviolet opened this issue Sep 29, 2019 · 4 comments
Closed

BUG: Infinite loop in DefaultRocketMQListenerContainer #151

shepherdviolet opened this issue Sep 29, 2019 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@shepherdviolet
Copy link

while ((Objects.isNull(interfaces) || 0 == interfaces.length) && Objects.nonNull(superclass)) {
interfaces = superclass.getGenericInterfaces();
superclass = targetClass.getSuperclass();
}

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:

    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();
    }
@RongtongJin
Copy link
Contributor

It's indeed a bug. Could you please submit a PR to fix it ?

@shepherdviolet
Copy link
Author

It's indeed a bug. Could you please submit a PR to fix it ?

When I am free, I will submit a PR, (* ̄︶ ̄)

@vongosling vongosling added the bug Something isn't working label Oct 28, 2019
@vongosling vongosling added this to the 2.0.4 milestone Oct 28, 2019
@ShannonDing ShannonDing modified the milestones: 2.0.4, 2.0.5 Oct 31, 2019
@zongtanghu
Copy link

This issue can assign to @zhangjidi2016.And firstly, this issue can assign to me!

@zongtanghu zongtanghu self-assigned this Dec 18, 2019
vongosling added a commit that referenced this issue Jan 2, 2020
[ISSUE #151] Fix the Infinite loop in DefaultRocketMQListenerContainer
@chenxubiao
Copy link

请问现在支持这种继承写法吗

AbstractRocketMQListener implement RocketMQListener

MyMsgListener extend AbstractRocketMQListener

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants