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

Matej Novotny manovotn at redhat.com
Tue Mar 13 05:36:28 EDT 2018


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


More information about the weld-dev mailing list