[weld-issues] [JBoss JIRA] (WELD-991) Incorrect check of bean type when obtaining contextual reference via BeanManager#getReference()

Ales Justin (JIRA) jira-events at lists.jboss.org
Mon Feb 27 11:31:36 EST 2012


     [ https://issues.jboss.org/browse/WELD-991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ales Justin updated WELD-991:
-----------------------------

    Fix Version/s: 2.0.0.Alpha2

    
> Incorrect check of bean type when obtaining contextual reference via BeanManager#getReference()
> -----------------------------------------------------------------------------------------------
>
>                 Key: WELD-991
>                 URL: https://issues.jboss.org/browse/WELD-991
>             Project: Weld
>          Issue Type: Bug
>    Affects Versions: 1.1.2.Final
>            Reporter: Martin Kouba
>             Fix For: 2.0.0.Alpha2
>
>
> CDI 1.0 section *11.3.1 Obtaining a contextual reference for a bean* states:
> "If the given type is not a bean type of the given bean, an IllegalArgumentException is thrown."
> However no such exception is thrown. Refer to CDI TCK test [1].
> After inspecting the source code I suppose the problem is probably related to following part of *org.jboss.weld.manager.BeanManagerImpl.getReference(Bean<?>, Type, CreationalContext<?>)*:
> {code}
> if (!Reflections.isAssignableFrom(bean.getTypes(), beanType))
> {
>  throw new IllegalArgumentException(SPECIFIED_TYPE_NOT_BEAN_TYPE, beanType, bean );
> }
> {code}
> All beans have the bean type *java.lang.Object* (2.2. Bean types) - since java.lang.Object is assignable from any class *Reflections.isAssignableFrom(bean.getTypes(), beanType)* will always return true.
> [1] https://github.com/jboss/cdi-tck/blob/master/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list