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

ApplicationListenerMethodAdapter can't be removed after targetBean destroy [SPR-17456] #21988

spring-projects-issues opened this issue Nov 2, 2018 · 0 comments
in: core status: waiting-for-triage


Copy link

@spring-projects-issues spring-projects-issues commented Nov 2, 2018

Pramy opened SPR-17456 and commented

I know a bean implement ApplicationListener will be remove from Context when it destroy,

but ApplicationListenerMethodAdapter can't be remove 

1.ParentContext invoke close method

2.Listener destroy

  it did not implements ApplicationListener when use @EventListener

3.NamedContext destroy

  it will invoke close method and publish close event, and parentContext will also publish close
  event, ApplicationListenerMethodAdapter working will invoke conetext#getBean

public class DemoApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context =, args);

    class Listener implements DisposableBean {

        public void close(ApplicationEvent event) {
            System.out.println("---------------invoke listener"+event );
        public void destroy() throws Exception {
            System.out.println("--------------------listener destroy-----------------------");

    // NamedContextFactory initialize before listener
    // NamedContextFactory destroy after listener
    public Listener listener() {
        //3.initialize context values
        return new Listener();

    public NamedContextFactory<NamedContextFactory.Specification> namedContextFactory() {
        return new NamedContextFactory<NamedContextFactory.Specification>(Config.class
        ,"demo","demo") {};

    class Config{}

Affects: 5.0.9, 5.0.10, 5.1.1, 5.1.2

Reference URL:


Referenced from: pull request #2006

@spring-projects-issues spring-projects-issues added status: waiting-for-triage type: enhancement in: core and removed type: enhancement labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core status: waiting-for-triage
None yet

No branches or pull requests

1 participant