Skip to content

Commit 2241ae1

Browse files
committed
GH-329 - Upgrade to Spring Boot 3.2 RC1.
Remove workaround of calling ApplicationListenerMethodAdapter.shouldHandle(…) reflectively.
1 parent 0189028 commit 2241ae1

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4242
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4343
<spring.version>6.0.12</spring.version> <!-- For Javadoc links only -->
44-
<spring-boot.version>3.2.0-M3</spring-boot.version>
44+
<spring-boot.version>3.2.0-RC1</spring-boot.version>
4545

4646
</properties>
4747

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

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.modulith.events.support;
1717

18-
import java.lang.reflect.Method;
1918
import java.time.Duration;
2019
import java.util.Collection;
2120
import java.util.List;
@@ -31,7 +30,6 @@
3130
import org.springframework.context.ApplicationListener;
3231
import org.springframework.context.PayloadApplicationEvent;
3332
import org.springframework.context.event.AbstractApplicationEventMulticaster;
34-
import org.springframework.context.event.ApplicationEventMulticaster;
3533
import org.springframework.context.event.ApplicationListenerMethodAdapter;
3634
import org.springframework.core.ResolvableType;
3735
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
@@ -46,9 +44,7 @@
4644
import org.springframework.modulith.events.core.TargetEventPublication;
4745
import org.springframework.transaction.event.TransactionPhase;
4846
import org.springframework.transaction.event.TransactionalApplicationListener;
49-
import org.springframework.transaction.event.TransactionalEventListener;
5047
import org.springframework.util.Assert;
51-
import org.springframework.util.ReflectionUtils;
5248

5349
/**
5450
* An {@link ApplicationEventMulticaster} to register {@link EventPublication}s in an {@link EventPublicationRegistry}
@@ -65,17 +61,12 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv
6561
implements IncompleteEventPublications, SmartInitializingSingleton {
6662

6763
private static final Logger LOGGER = LoggerFactory.getLogger(PersistentApplicationEventMulticaster.class);
68-
private static final Method SUPPORTS_METHOD = ReflectionUtils.findMethod(ApplicationListenerMethodAdapter.class,
69-
"shouldHandle", ApplicationEvent.class, Object[].class);
64+
7065
static final String REPUBLISH_ON_RESTART = "spring.modulith.republish-outstanding-events-on-restart";
7166

7267
private final @NonNull Supplier<EventPublicationRegistry> registry;
7368
private final @NonNull Supplier<Environment> environment;
7469

75-
static {
76-
ReflectionUtils.makeAccessible(SUPPORTS_METHOD);
77-
}
78-
7970
/**
8071
* Creates a new {@link PersistentApplicationEventMulticaster} for the given {@link EventPublicationRegistry}.
8172
*
@@ -228,18 +219,13 @@ private static Object getEventToPersist(ApplicationEvent event) {
228219
: event;
229220
}
230221

231-
@SuppressWarnings("null")
232222
private static boolean matches(ApplicationEvent event, Object payload, ApplicationListener<?> listener) {
233223

234224
// Verify general listener matching by eagerly evaluating the condition
235-
if (ApplicationListenerMethodAdapter.class.isInstance(listener)) {
225+
if (ApplicationListenerMethodAdapter.class.isInstance(listener)
226+
&& !((ApplicationListenerMethodAdapter) listener).shouldHandle(event)) {
236227

237-
boolean result = (boolean) ReflectionUtils.invokeMethod(SUPPORTS_METHOD, listener, event,
238-
new Object[] { payload });
239-
240-
if (!result) {
241-
return false;
242-
}
228+
return false;
243229
}
244230

245231
return ConditionalEventListener.class.isInstance(listener)

0 commit comments

Comments
 (0)