Hello Martin

I use weld 2.4; I tested this in liberty and wildfly-10.1.0.Final

Regards
Benjamin




From:        Martin Kouba <mkouba@redhat.com>
To:        Benjamin Confino <BENJAMIC@uk.ibm.com>, weld-dev@lists.jboss.org,
Cc:        Emily Jiang <EMIJIANG@uk.ibm.com>
Date:        09/08/2017 11:42
Subject:        Re: [weld-dev] Dependent Scoped bean aquired by CDI.current() is not destroyed




Hi Benjamin,

the lifecycle of @Dependent instances created through
javax.enterprise.inject.spi.CDI is not well defined. So it's always
better to destroy such instances when not needed. However, it would make
sense to destroy such instances during shutdown.

I believe this works in Weld SE. What environment/runtime do you use?

Martin

Dne 9.8.2017 v 11:52 Benjamin Confino napsal(a):
> Hello
>
> I have a servlet that acquires two instances of a dependent scoped bean.
> The first is aquired by @Inject Instance<CdiBean> the second is acquired
> via CDI.current().select(CdiBean.class).get().
>
> I can see that the first instance's @PreDestroy is called when I shut
> down the application. However @PreDestroy is not called on the instance
> acquired CDI.current. Here is the source:
>
>
>
> My question is, is this behaviour intentional? And if it is, can you
> please link me to the appropriate part of the spec that says when we
> should expect a @Dependent bean created by CDI.current to be destroyed?
> I have a customer concerned about this causing a potential memory leak.
>
> Regards
> Benjamin
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>
>
> _______________________________________________
> weld-dev mailing list
> weld-dev@lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/weld-dev
>

--
Martin Kouba
Senior Software Engineer
Red Hat, Czech Republic



Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU