Skip to content

ApplicationListenerMethodAdapter supports non-matching generic events #30399

Closed
@odrotbohm

Description

@odrotbohm

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.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions