Skip to content

Commit ff32c60

Browse files
committed
GH-239 - Removed workaround after the downstream issue has been fixed in Spring Framework.
Related ticket: GH-186, spring-projects/spring-framework#30399.
1 parent 0e87964 commit ff32c60

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/support/PersistentApplicationEventMulticaster.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,34 +127,6 @@ public void afterSingletonsInstantiated() {
127127
publications.forEach(this::invokeTargetListener);
128128
}
129129

130-
/**
131-
* Temporary workaround for an issue in Spring Framework that lets ApplicationListenerMethodAdapter match all generic
132-
* events with unresolved generics.
133-
*
134-
* @see <a href=
135-
* "https://github.com/spring-projects/spring-framework/issues/30399">https://github.com/spring-projects/spring-framework/issues/30399</a>
136-
*/
137-
@Override
138-
@SuppressWarnings("unchecked")
139-
protected boolean supportsEvent(ApplicationListener<?> listener, ResolvableType eventType, Class<?> sourceType) {
140-
141-
var result = super.supportsEvent(listener, eventType, sourceType);
142-
143-
if (!super.supportsEvent(listener, eventType, sourceType)
144-
|| !(listener instanceof ApplicationListenerMethodAdapter adapter)) {
145-
return result;
146-
}
147-
148-
var actualEventType = ResolvableType.forClass(PayloadApplicationEvent.class).isAssignableFrom(eventType)
149-
? eventType.getGeneric()
150-
: eventType;
151-
152-
var declaredEventTypes = (List<ResolvableType>) ReflectionUtils.getField(DECLARED_EVENT_TYPES_FIELD, adapter);
153-
154-
return declaredEventTypes.stream()
155-
.anyMatch(it -> it.isAssignableFrom(actualEventType.getRawClass()));
156-
}
157-
158130
private void invokeTargetListener(EventPublication publication) {
159131

160132
var listeners = new TransactionalEventListeners(

spring-modulith-events/spring-modulith-events-core/src/test/java/org/springframework/modulith/events/support/PersistentApplicationEventMulticasterIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ SampleEventListener listener() {
6060
@Autowired ApplicationEventPublisher publisher;
6161
@Autowired EventPublicationRepository repository;
6262

63-
@Test // GH-186
63+
@Test // GH-186, GH-239
6464
void doesNotPublishGenericEventsToListeners() throws Exception {
6565

6666
publisher.publishEvent(new SomeGenericEvent<>());

0 commit comments

Comments
 (0)