Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider generics on ApplicationListener @Bean methods #23178

Closed
philwebb opened this issue Jun 21, 2019 · 4 comments
Closed

Consider generics on ApplicationListener @Bean methods #23178

philwebb opened this issue Jun 21, 2019 · 4 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@philwebb
Copy link
Member

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.

@sdeleuze
Copy link
Contributor

Linked to #21411?

@philwebb
Copy link
Member Author

No so much since these are actual @Bean methods. Probably somewhat related to #23056 and the general problem of determining type details from a bean definition.

@jhoeller jhoeller self-assigned this Jun 21, 2019
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 21, 2019
@jhoeller jhoeller added this to the 5.2 RC1 milestone Jun 21, 2019
@odrotbohm
Copy link
Member

#15303 looks like a duplicate of this.

@sdeleuze
Copy link
Contributor

@odrotbohm Good point, that's the one I was trying to find.

artembilan added a commit to artembilan/spring-kafka that referenced this issue Jul 22, 2019
After introducing a `BeanDefinition.getResolvableType()` we have
several failed builds because of `NoSuchMethodError`.
Looks like interface and its implementation classes are loaded from
different versions.

* Exclude `org.springframework` from `spring-data-commons` to avoid
CLASSPATH conflicts

Related to
https://build.spring.io/browse/SK-SON-1242/
spring-projects/spring-framework#23178
garyrussell pushed a commit to spring-projects/spring-kafka that referenced this issue Jul 22, 2019
* Bump to the latest BUILD-SNAPSHOTs

After introducing a `BeanDefinition.getResolvableType()` we have
several failed builds because of `NoSuchMethodError`.
Looks like interface and its implementation classes are loaded from
different versions.

* Exclude `org.springframework` from `spring-data-commons` to avoid
CLASSPATH conflicts

Related to
https://build.spring.io/browse/SK-SON-1242/
spring-projects/spring-framework#23178

* * Fix race condition in `testSeekToLastOnIdle()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants