ApplicationListenerMethodAdapter
wrongly indicates it would support a generic event type exposing unresolved generics, even if there's no type relationship between the events at all. See the following, failing test case:
class ApplicationListenerMethodAdapterTests {
@Test
void testName() throws Exception {
var method = ApplicationListenerMethodAdapterTests.class.getDeclaredMethod("listener", SomeOtherEvent.class);
var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method);
assertThat(adapter.supportsEventType(ResolvableType.forClass(SomeGenericEvent.class))).isFalse();
}
@EventListener
void listener(SomeOtherEvent event) {}
static class SomeGenericEvent<T> {}
static class SomeOtherEvent {}
}
Note how the adapter signals the event listener method would support SomeGenericEvent
when it clearly doesn't.
Comment From: sbrannen
Thanks for reporting the issue, @odrotbohm.
It looks like the fallback to return eventType.hasUnresolvableGenerics()
in ApplicationListenerMethodAdapter.supportsEventType(ResolvableType)
is the culprit.
Comment From: odrotbohm
Yes, I ended up at the same place. Wonder whether this needs to be augmented with at least a raw type assignability check?