[weld-dev] Dependent Scoped bean aquired by CDI.current() is not destroyed

Benjamin Confino BENJAMIC at uk.ibm.com
Wed Aug 9 05:52:13 EDT 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170809/41fc5f05/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestServlet.java
Type: application/octet-stream
Size: 1130 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/weld-dev/attachments/20170809/41fc5f05/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CdiBean.java
Type: application/octet-stream
Size: 699 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/weld-dev/attachments/20170809/41fc5f05/attachment-0001.obj 


More information about the weld-dev mailing list