[weld-dev] Potential bug with Typed not affecting if a ProducerMethod is proxiable.

Martin Kouba mkouba at redhat.com
Thu Mar 15 04:18:59 EDT 2018


It is true that @Typed is only used to restrict the set of bean types 
used during resolution. And so it has no direct effect on proxyability 
checks, except that WELD-2466 is about the fact that Weld incorrectly 
checks all the bean types of a bean in 
BeanManager#getInjectableReference. So Benjamin's attempt makes some 
sense ;-). Unfortunately, it seems the only way to fix this is the PR 
attached to WELD-2466.

Martin

Dne 13.3.2018 v 10:36 Matej Novotny napsal(a):
> Hi,
> 
> comments inline.
> 
> Matej
> 
> ----- Original Message -----
>> From: "Benjamin Confino" <BENJAMIC at uk.ibm.com>
>> To: weld-dev at lists.jboss.org
>> Cc: "Emily Jiang" <EMIJIANG at uk.ibm.com>
>> Sent: Monday, March 12, 2018 6:40:27 PM
>> Subject: [weld-dev] Potential bug with Typed not affecting if a	ProducerMethod is proxiable.
>>
>> Hello
>>
>> I can see something that might be a bug in weld. I attempted to work
>> around https://issues.jboss.org/projects/WELD/issues/WELD-2466 by using
>> the at Typed annotation on a Producer Method to exclude the unproxiable Types
>> and thus avoid getting caught by the failing isBeanProxiable check.
>> However the annotation did not affect whether or not the ProducerMethod is
>> proxiable. This might be a second bug.
>>
>> I have uploaded a recreate application which I have verified against
>> Wildfly 11.0.0 here: https://github.com/benjamin-confino/TypedProducerBug
> 
> Thanks for reproducer, checking it now.
> 
>>
>> To recreate you can download the pre-compiled binary from github, deploy
>> it to a version of Wildfly without the fix for WELD-2466, and visit the
>> url http://localhost:8080/WeldRecreateProducesExtendedAbstract/inheritance
>> this will trigger a call to getInjectableReference() which will fail
>> because the ProducerMethod for recreate.BeanProducer.produceBean() is not
>> proxiable.
>>
>> If you debug into constructor for ProducerMethod at line 76 you will see
>> that the proxiable flag is set using method.getTypeClosures() ; which
>> returns all the associated types, rather than just those specified with
>> the Typed() paramater.
>>
>> Is this the correct behaviour? Should a ProducerMethod be unproxiable even
>> with Typed limiting the bean types to proxiable types?
> 
> I think this is correct behaviour because:
> * Weld needs to proxy whole class hierarchy, we cannot just skip one underlying class when creating the proxy object
> * @Typed is then used to determine where can this bean be injected, e.g. which bean types are used to match it against required types of each injection point
> 
> Therefore, @Typed is not really connected to proxyability but rather to assignability of that produced bean to a given injection point.
> 
> I'll double check this but I really think it's correct behaviour.
> 
>>
>> Regards
>> Benjamin
>> Unless stated otherwise above:
>> IBM United Kingdom Limited - Registered in England and Wales with number
>> 741598.
>> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>>
>> _______________________________________________
>> weld-dev mailing list
>> weld-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/weld-dev
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
> 

-- 
Martin Kouba
Senior Software Engineer
Red Hat, Czech Republic


More information about the weld-dev mailing list