Skip to content

Consider generics on ApplicationListener @Bean methods #23178

Closed
@philwebb

Description

@philwebb

See spring-projects/spring-boot#17291 for background.

Currently using this pattern to define an ApplicationListener:

@Bean
public ApplicationListener<ClassPathChangedEvent>  someListener() {
    // ...
}

Will result in a lot of cast class exception because the listener is called for every event. It would be nice if we could consider the generic signature of the bean method and only call listeners that match it.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions