Skip to content

Consider generics on ApplicationListener @Bean methods #23178

Closed

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.

Activity

  1. added
    status: waiting-for-triage
    on Jun 21, 2019
  2. sdeleuze commented on Jun 21, 2019

    @sdeleuze
    Contributor

    Linked to #21411?

  3. philwebb commented on Jun 21, 2019

    @philwebb
    MemberAuthor

    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.

  4. self-assigned this
    on Jun 21, 2019
  5. added
    in: core
    type: enhancement
    and removed
    status: waiting-for-triage
    on Jun 21, 2019
  6. added this to the 5.2 RC1 milestone on Jun 21, 2019
  7. odrotbohm commented on Jun 21, 2019

    @odrotbohm
    Member

    #15303 looks like a duplicate of this.

  8. sdeleuze commented on Jun 23, 2019

    @sdeleuze
    Contributor

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

  9. added a commit that references this issue on Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions