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

Cannot declare multiple disposal methods for this producer method.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.2.0.Beta2
    • 2.1.2.Final
    • None
    • None
    • Hide

      Example code:

      @Singleton
      public class Bean {
      public void produce(@RequestScoped Something instance)

      { ... }
      public void dispose(@Disposes Something instance) { ... }

      public void produceQualified(@Qualified Something instance)

      { ... }
      public void disposeQualified(@Disposes @Qualified Something instance) { ... }

      }

      @Qualifier
      @Target(

      { TYPE, FIELD, METHOD, PARAMETER }

      )
      @Retention(RUNTIME)
      @Documented
      public @interface Qualified {
      // some custom qualifier
      }

      Show
      Example code: @Singleton public class Bean { public void produce(@RequestScoped Something instance) { ... } public void dispose(@Disposes Something instance) { ... } public void produceQualified(@Qualified Something instance) { ... } public void disposeQualified(@Disposes @Qualified Something instance) { ... } } @Qualifier @Target( { TYPE, FIELD, METHOD, PARAMETER } ) @Retention(RUNTIME) @Documented public @interface Qualified { // some custom qualifier }

    Description

      After upgrading from WELD 1.1.8.Final to 2.1.2.Final, I started to experience the following behavior.

      I have two producer and two dispose methods producing/disposing instance of the same type. One pair is distinguished by a qualifier, the other pair is unqualified.

      In version 1.1.8 this worked fine, the two couples where paired correctly.

      In 2.1.2, this code produces an error

      WELD-000077: Cannot declare multiple disposal methods for this producer method.

      Producer method: org.jboss.weld.bootstrap.ConcurrentBeanDeployer@3c720215
      Disposal methods:

      • Disposer method [[BackedAnnotatedMethod] public Bean.disposeQualified(@Disposes @Qualified Something)],
      • Disposer method [[BackedAnnotatedMethod] public Bean.dispose(@Disposes Something)]
        at org.jboss.weld.bootstrap.AbstractBeanDeployer.resolveDisposalMethod(AbstractBeanDeployer.java:193)
        at org.jboss.weld.bootstrap.AbstractBeanDeployer.createProducerMethod(AbstractBeanDeployer.java:216)
        at org.jboss.weld.bootstrap.AbstractBeanDeployer.createProducerMethods(AbstractBeanDeployer.java:202)
        at org.jboss.weld.bootstrap.AbstractBeanDeployer.createObserversProducersDisposers(AbstractBeanDeployer.java:179)

      IMO this is because the unqualified disposer method, claims that it can dispose any products of the type, qualified or not. Trying to resolve disposing method of @Qualified Something is thus ambiguous.

      Is this intentional change in behavior? Is it possible to somehow specify that the unqualified disposal method should be used only for unqualified products of Something?

      Attachments

        Activity

          People

            rhn-engineering-jharting Jozef Hartinger
            msevcenko Michal Ševčenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: