-
Notifications
You must be signed in to change notification settings - Fork 626
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
GH-2456: Suppress Duplicate Annotations with Spy #2457
Conversation
Resolves spring-projects#2456 When spying a `@RabbitListener` bean, duplicate methods are resolved as well as duplicate class level `@RabbitListener` annotations. **cherry-pick to 2.4.x** (will require instanceof polishing for Java 8)
does this confirm that premise of the Thanks |
Yes, that's why I added the I couldn't detect any difference at runtime - the mock method is still in the stack trace (set a breakpoint in This doesn't actually make any difference to the spy, it just avoids us finding both sets of annotations which causes duplicate containers/methods. |
... and cherry-picked to |
@@ -339,7 +339,8 @@ private TypeMetadata buildMetadata(Class<?> targetClass) { | |||
multiMethods.add(method); | |||
} | |||
} | |||
}, ReflectionUtils.USER_DECLARED_METHODS); | |||
}, ReflectionUtils.USER_DECLARED_METHODS | |||
.and(meth -> !meth.getDeclaringClass().getName().contains("$MockitoMock$"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cherry-picked to 2.4.x breaks compatibility with Spring Framework 5.2, USER_DECLARED_METHODS comes with a and
method only after 5.3.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spring Framework 5.2.x is no longer supported as OSS and goes out of commercial support at the end of the year.
https://spring.io/projects/spring-framework#support
However, 2.4.x has always used Spring Framework 5.3.x; it has never supported being run on 5.2.x. Here is the version on the v2.4.0 tag:
Line 66 in 6235c7b
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.3.13' |
It currently requires 5.3.30.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the reference said it works with 5.2.x.
And in fact, everything else looks good with 5.2.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bug in the documentation but, in any case, as I said 5.2.x is out of support anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made an exception and made the change dcc49ba
The next release is mid-October.
But I still recommend that you move to a supported version of Spring Framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I'd like to upgrade, but it's out of my control.
Resolves #2456
When spying a
@RabbitListener
bean, duplicate methods are resolved as well as duplicate class level@RabbitListener
annotations.cherry-pick to 2.4.x (will require instanceof polishing for Java 8)