[cdi-dev] cyclic references

Pete Muir pmuir at redhat.com
Mon Nov 26 08:53:54 EST 2012


I don't believe the spec is updated for this. BTW I assume you mean *calling* cyclic references from those methods?

On 24 Nov 2012, at 16:58, Mark Struberg wrote:

> Hi Folks!
> 
> I know we already discussed that cyclic references in @PostConstruct and @Inject methods are not allowed (btw, did we also nail this down in the spec properly? This is implicitly defined in commons-annotations).
> 
> But what about @PreDestroy? As the destroy order is not defined for normalscoped beans it could happen that a bean already got wiped and destroyed while another one likes to access it. So it's not only a problem of cycles, but might also happen without.
> 
> sample:
> 
> @RequestScoped
> 
> public class BeanA {
>   @Inject BeanB b;
> 
>   @PreDestroy
>   public void destroyMe() {
>     b.dosomething();
>   }
> }
> 
> and 
> 
> 
> @RequestScoped
> 
> public class BeanB {
>   public void dosomething() {..}
> 
>   @PreDestroy
>   public void dropDatabaseConnection() {...}
> 
> }
> 
> Now lets imagine that BeanB got destroyed earlier than BeanA ....
> 
> 
> It's atm purely random. Imo this is ok, but should we point users to this behaviour?
> 
> LieGrue,
> strub
> 
> 
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev




More information about the cdi-dev mailing list