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

bean-lookup issue in Context#get(Contextual, CreationalContext)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.1.2.Final
    • 1.1.1.Final
    • Scopes & Contexts
    • None

      this is a very special case which used to work before weld v1.1.1

      e.g.:
      Set<Bean<?>> beans1 = beanManager.getBeans(MyBean.class);

      Class beanClass = beans.iterator().next().getBeanClass();
      Set<Annotation> qualifiers = beans.iterator().next().getQualifiers();
      Set<Bean<?>> beans2 = beanManager.getBeans(beanClass, qualifiers.toArray(new Annotation[qualifiers.size()]));

      beans1 is the same as beans2

      that works without problems.

      if you use the same in
      Context#get(Contextual, CreationalContext)
      it doesn't work. i haven't looked at the details but it might be due to the performance optimizations.

      the following example isn't that useful (so please don't ask for the reason) - it's just the minimal code to reproduce the issue.

      public <T> T get(Contextual<T> component, CreationalContext<T> creationalContext)
      {
      Class beanClass = ((Bean<T>)component).getBeanClass();
      Set<Annotation> qualifiers = ((Bean<T>)component).getQualifiers();

      Set<Bean<?>> beans = CdiUtils.getBeanManager().getBeans(beanClass, qualifiers.toArray(new Annotation[qualifiers.size()]));
      //beans is empty
      }

      it isn't specified that it should work but it used to work with weld and it also works with owb.
      since there is (imo) no reason why it shouldn't work, it would be great if it gets fixed!

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              gpetracek Gerhard Petracek (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: