oghenez / mycila

Automatically exported from code.google.com/p/mycila
0 stars 0 forks source link

JSR250 @PreDestroy is invoked more than once #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I've found a problem with @PreDestroy methods being invoked more than once. It 
happens when providers return the same object. With linked bindinds Interface 
-> Class, Guice will create an internal jit ConstructorBinding for Class so 
Injector.getAllBindings() will return two providers that return the same object.

It should be solvable by gathering all objects in an IdentityHashSet and then 
destroy them.

Here's a failing test case, http://pastie.org/2176603

The last test shows that when binding a Provider, it will get its 
@PostConstruct called since Guice injects into it, but it will not get its 
@PreDestroy called. Maybe this is intentional. The same things goes for objects 
that get passed to injectMembers(), used with a MembersInjector() and 
Binder.requestInjection() i guess.

Original issue reported on code.google.com by totobobi...@gmail.com on 7 Jul 2011 at 8:52

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 7 Aug 2011 at 5:23

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 7 Aug 2011 at 6:13

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 7 Aug 2011 at 7:45