-
-
Save ericbottard/ad6da5559257fbcb0325 to your computer and use it in GitHub Desktop.
This shows leakage of Class<T> by AbstractApplicationEventMulticaster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @author ebottard | |
*/ | |
public class Foo { | |
public static void main(String[] args) throws IOException { | |
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(); | |
parent.register(Parent.class); | |
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext(); | |
child.register(Child.class); | |
// child.setParent(parent); | |
parent.refresh(); | |
child.refresh(); | |
child.publishEvent(new MyEvent(child)); | |
child.close(); | |
child = null; | |
System.in.read(); | |
} | |
public static class MyEvent extends ApplicationEvent { | |
/** | |
* @param source | |
*/ | |
public MyEvent(Object source) { | |
super(source); | |
// TODO Auto-generated constructor stub | |
} | |
} | |
@Configuration() | |
public static class Parent { | |
} | |
@Configuration() | |
public static class Child { | |
@Bean | |
public ApplicationListener<MyEvent> foo() { | |
return new ApplicationListener<Foo.MyEvent>() { | |
@Override | |
public void onApplicationEvent(MyEvent event) { | |
System.out.println(event); | |
} | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment