-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Add support for explicit generic type in PayloadApplicationEvent #24599
Add support for explicit generic type in PayloadApplicationEvent #24599
Conversation
spring-context/src/main/java/org/springframework/context/PayloadApplicationEvent.java
Outdated
Show resolved
Hide resolved
@chenqimiao thank you! |
@snicoll My pleasure |
org.springframework.context.event.ApplicationListenerMethodAdapter#onApplicationEvent |
This PR is to make event mechanisms better support generics.
When I publish an event which contains generics via
org.springframework.context.support.AbstractApplicationContext#publishEvent(java.lang.Object, org.springframework.core.ResolvableType)
, I find that corresponding listener does not get event message. Please see the unit test cases in my PR.The unit test method of named publishEventWithGeneric fail before this PR submission
.So, I think we can add a payloadType field to PayloadApplicationEvent to fix this.
In addition, this fix code also can cache the type information of the payload to improve performance.
Thank you for reading and look forward to your reply.