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

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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.1.2
    • Fix Version/s: 1.1.3
    • Component/s: Context and Scopes
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: