Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2176

Weld fails to call disposal method for instances created by static producer method/field

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.3.5.Final, 3.0.0.Alpha17
    • 2.3.4.Final, 3.0.0.Alpha16
    • None
    • None

      When you have something like this:

      public class FooDisposal { 
      
          @Produces
          @Tame
          static Foo foo() {
              return new Foo();
          }
      
          public void disposeFoo(@Disposes @Tame Foo foo) {
              System.out.println("------------------------------------- DISPOSED");
          }
      }
      

      then Weld silently fails with following message in log:

      19:26:21,933 ERROR [org.jboss.weld.Bean] (default task-17) WELD-000019: Error destroying an instance org.jboss.cdi.tck.tests.implementation.disposal.method.definition.broken.enterprise.remoteMethod.Foo@17bc197a of Producer Method [Foo] with qualifiers [@Tame @Any] declared as [[BackedAnnotatedMethod] @Produces @Tame static org.jboss.cdi.tck.tests.implementation.disposal.method.definition.broken.enterprise.remoteMethod.FooDisposal.foo()]
      

      I guess the underlying problem is NPE coming from https://github.com/weld/core/blob/master/impl/src/main/java/org/jboss/weld/injection/producer/AbstractMemberProducer.java#L132 but that's just a guess.

              mkouba@redhat.com Martin Kouba
              tremes1@redhat.com Tomas Remes
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: