Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-627

Automatically destroy @Dependent contextual instances created with Instance<T>

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.1.2
    • 1.1.3
    • Context and Scopes
    • None

    Description

      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>

      Attachments

        Activity

          People

            struberg Mark Struberg
            struberg Mark Struberg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: