diff --git a/framework-platform/framework-platform.gradle b/framework-platform/framework-platform.gradle index 06c649b7e8..fc172371ef 100644 --- a/framework-platform/framework-platform.gradle +++ b/framework-platform/framework-platform.gradle @@ -9,7 +9,7 @@ javaPlatform { dependencies { api(platform("com.fasterxml.jackson:jackson-bom:2.15.2")) api(platform("io.micrometer:micrometer-bom:1.10.8")) - api(platform("io.netty:netty-bom:4.1.93.Final")) + api(platform("io.netty:netty-bom:4.1.94.Final")) api(platform("io.netty:netty5-bom:5.0.0.Alpha5")) api(platform("io.projectreactor:reactor-bom:2022.0.8")) api(platform("io.rsocket:rsocket-bom:1.1.3")) @@ -19,7 +19,7 @@ dependencies { api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.7.1")) api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.5.1")) api(platform("org.junit:junit-bom:5.9.3")) - api(platform("org.mockito:mockito-bom:5.3.1")) + api(platform("org.mockito:mockito-bom:5.4.0")) constraints { api("com.fasterxml:aalto-xml:1.3.2") @@ -100,10 +100,10 @@ dependencies { api("org.apache.httpcomponents.client5:httpclient5:5.2.1") api("org.apache.httpcomponents.core5:httpcore5-reactive:5.2.1") api("org.apache.poi:poi-ooxml:5.2.3") - api("org.apache.tomcat.embed:tomcat-embed-core:10.1.9") - api("org.apache.tomcat.embed:tomcat-embed-websocket:10.1.9") - api("org.apache.tomcat:tomcat-util:10.1.8") - api("org.apache.tomcat:tomcat-websocket:10.1.8") + api("org.apache.tomcat.embed:tomcat-embed-core:10.1.10") + api("org.apache.tomcat.embed:tomcat-embed-websocket:10.1.10") + api("org.apache.tomcat:tomcat-util:10.1.10") + api("org.apache.tomcat:tomcat-websocket:10.1.10") api("org.aspectj:aspectjrt:1.9.19") api("org.aspectj:aspectjtools:1.9.19") api("org.aspectj:aspectjweaver:1.9.19") diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java index 8b9e6d4b94..f8c4e331fa 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java @@ -335,11 +335,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv verify(this.context, times(2)).getBean("testBean"); } - // see https://github.com/spring-projects/spring-framework/issues/30399 - @Test + @Test // gh-30399 void simplePayloadDoesNotSupportArbitraryGenericEventType() throws Exception { - var method = SampleEvents.class.getDeclaredMethod("handleString", String.class); - var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); + Method method = SampleEvents.class.getDeclaredMethod("handleString", String.class); + ApplicationListenerMethodAdapter adapter = createTestInstance(method); assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, Integer.class)))) .as("handleString(String) with EntityWrapper").isFalse(); @@ -349,11 +348,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv .as("handleString(String) with String").isTrue(); } - // see https://github.com/spring-projects/spring-framework/issues/30399 - @Test + @Test // gh-30399 void genericPayloadDoesNotSupportArbitraryGenericEventType() throws Exception { - var method = SampleEvents.class.getDeclaredMethod("handleGenericStringPayload", EntityWrapper.class); - var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); + Method method = SampleEvents.class.getDeclaredMethod("handleGenericStringPayload", EntityWrapper.class); + ApplicationListenerMethodAdapter adapter = createTestInstance(method); assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClass(EntityWrapper.class)))) .as("handleGenericStringPayload(EntityWrapper) with EntityWrapper").isFalse(); @@ -363,11 +361,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv .as("handleGenericStringPayload(EntityWrapper) with EntityWrapper").isTrue(); } - // see https://github.com/spring-projects/spring-framework/issues/30399 - @Test + @Test // gh-30399 void rawGenericPayloadDoesNotSupportArbitraryGenericEventType() throws Exception { - var method = SampleEvents.class.getDeclaredMethod("handleGenericAnyPayload", EntityWrapper.class); - var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); + Method method = SampleEvents.class.getDeclaredMethod("handleGenericAnyPayload", EntityWrapper.class); + ApplicationListenerMethodAdapter adapter = createTestInstance(method); assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClass(EntityWrapper.class)))) .as("handleGenericAnyPayload(EntityWrapper) with EntityWrapper").isTrue(); @@ -381,10 +378,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv .as("handleGenericAnyPayload(EntityWrapper) with List").isFalse(); } - @Test + @Test // gh-30399 void genericApplicationEventSupportsSpecificType() throws Exception { - var method = SampleEvents.class.getDeclaredMethod("handleGenericString", GenericTestEvent.class); - var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); + Method method = SampleEvents.class.getDeclaredMethod("handleGenericString", GenericTestEvent.class); + ApplicationListenerMethodAdapter adapter = createTestInstance(method); assertThat(adapter.supportsEventType(ResolvableType.forClass(GenericTestEvent.class))) .as("handleGenericString(GenericTestEvent) with GenericTestEvent").isTrue(); @@ -394,10 +391,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv .as("handleGenericString(GenericTestEvent) with GenericTestEvent").isTrue(); } - @Test + @Test // gh-30399 void genericRawApplicationEventSupportsRawTypeAndAnySpecificType() throws Exception { - var method = SampleEvents.class.getDeclaredMethod("handleGenericRaw", GenericTestEvent.class); - var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); + Method method = SampleEvents.class.getDeclaredMethod("handleGenericRaw", GenericTestEvent.class); + ApplicationListenerMethodAdapter adapter = createTestInstance(method); assertThat(adapter.supportsEventType(ResolvableType.forClass(GenericTestEvent.class))) .as("handleGenericRaw(GenericTestEvent) with GenericTestEvent").isTrue(); @@ -407,6 +404,20 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv .as("handleGenericRaw(GenericTestEvent) with GenericTestEvent").isTrue(); } + @Test // gh-30399 + void unrelatedApplicationEventDoesNotSupportRawTypeOrAnySpecificType() throws Exception { + Method method = SampleEvents.class.getDeclaredMethod("handleUnrelated", ContextRefreshedEvent.class); + ApplicationListenerMethodAdapter adapter = createTestInstance(method); + + assertThat(adapter.supportsEventType(ResolvableType.forClass(GenericTestEvent.class))) + .as("handleUnrelated(ContextRefreshedEvent) with GenericTestEvent").isFalse(); + assertThat(adapter.supportsEventType(ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class))) + .as("handleUnrelated(ContextRefreshedEvent) with GenericTestEvent").isFalse(); + assertThat(adapter.supportsEventType(ResolvableType.forClassWithGenerics(GenericTestEvent.class, Integer.class))) + .as("handleUnrelated(ContextRefreshedEvent) with GenericTestEvent").isFalse(); + } + + private void supportsEventType(boolean match, Method method, ResolvableType eventType) { ApplicationListenerMethodAdapter adapter = createTestInstance(method); assertThat(adapter.supportsEventType(eventType)) @@ -462,6 +473,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv public void handleGenericRaw(GenericTestEvent event) { } + @EventListener + public void handleUnrelated(ContextRefreshedEvent event) { + } + @EventListener public void handleString(String payload) { }