You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Mark Struberg (Commented) (JIRA)" <ji...@apache.org> on 2011/10/30 12:29:32 UTC

[jira] [Commented] (OWB-627) Automatically destroy @Dependent contextual instances created with Instance

    [ https://issues.apache.org/jira/browse/OWB-627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13139592#comment-13139592 ] 

Mark Struberg commented on OWB-627:
-----------------------------------

... or just store all the created @Dependent contextual instances within the CreationalContext of it's parent!

Going down this route now.
                
> Automatically destroy @Dependent contextual instances created with Instance<T>
> ------------------------------------------------------------------------------
>
>                 Key: OWB-627
>                 URL: https://issues.apache.org/jira/browse/OWB-627
>             Project: OpenWebBeans
>          Issue Type: Improvement
>          Components: Context and Scopes
>    Affects Versions: 1.1.2
>            Reporter: Mark Struberg
>            Assignee: Mark Struberg
>            Priority: Critical
>             Fix For: 1.1.3
>
>
> See https://issues.jboss.org/browse/CDI-139 for the problem.
> Consider the following code:
> @Dependent
> public class MyClass {
>   ...
> }
> private @Inject Instance<MyClass> inst;
> public void doSomething() {
>   MyClass dings = inst.select(...).get()
> }
> The problem here is that the @Dependent MyClass doesn't get injected into some other class, thus it doesn't share any lifecycle. Thus it will never get destroyed properly, and it's mem will also not get freed.
> The proper solution to that (as I explained in CDI-139) is to store T, the CreationalContext<T> and Contextual<T> which got used to create T in a List and destroy them properly via a @PreDestroy in Instance<T>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira