GH-239 - Removed workaround after the downstream issue has been fixed in Spring Framework.

Related ticket: GH-186, spring-projects/spring-framework#30399.
This commit is contained in:
Oliver Drotbohm
2023-07-17 13:15:50 +02:00
parent 0e879640ef
commit ff32c609fc
2 changed files with 1 additions and 29 deletions

View File

@@ -127,34 +127,6 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv
publications.forEach(this::invokeTargetListener);
}
/**
* Temporary workaround for an issue in Spring Framework that lets ApplicationListenerMethodAdapter match all generic
* events with unresolved generics.
*
* @see <a href=
* "https://github.com/spring-projects/spring-framework/issues/30399">https://github.com/spring-projects/spring-framework/issues/30399</a>
*/
@Override
@SuppressWarnings("unchecked")
protected boolean supportsEvent(ApplicationListener<?> listener, ResolvableType eventType, Class<?> sourceType) {
var result = super.supportsEvent(listener, eventType, sourceType);
if (!super.supportsEvent(listener, eventType, sourceType)
|| !(listener instanceof ApplicationListenerMethodAdapter adapter)) {
return result;
}
var actualEventType = ResolvableType.forClass(PayloadApplicationEvent.class).isAssignableFrom(eventType)
? eventType.getGeneric()
: eventType;
var declaredEventTypes = (List<ResolvableType>) ReflectionUtils.getField(DECLARED_EVENT_TYPES_FIELD, adapter);
return declaredEventTypes.stream()
.anyMatch(it -> it.isAssignableFrom(actualEventType.getRawClass()));
}
private void invokeTargetListener(EventPublication publication) {
var listeners = new TransactionalEventListeners(

View File

@@ -60,7 +60,7 @@ class PersistentApplicationEventMulticasterIntegrationTests {
@Autowired ApplicationEventPublisher publisher;
@Autowired EventPublicationRepository repository;
@Test // GH-186
@Test // GH-186, GH-239
void doesNotPublishGenericEventsToListeners() throws Exception {
publisher.publishEvent(new SomeGenericEvent<>());