[
https://jira.jboss.org/browse/WELD-705?page=com.atlassian.jira.plugin.sys...
]
Roberto Chinnici commented on WELD-705:
---------------------------------------
Stuart, Pete,
I think you misunderstood the issue.
We have two bean classes:
class BeanOne { @Inject BeanManager beanManager; }
class BeanTwo extends BeanOne {}
We also have an extension. The extension calls
ProcessAnnotatedType.setAnnotatedType(AnnotatedType) for both BeanOne and BeanTwo,
replacing the original annotated types. The new annotated types don't have any
annotated fields. I.e. the AnnotatedField for beanManager is not present in either
annotated type.
What we see is that, when we create a BeanTwo instance, the inherited beanManager field is
injected. This is against the spec: the container must use the AnnotatedType set by the
extension, not the original one.
We also noticed that, when we create BeanOne instances, injection into the beanManager
field does not happen. This is correct behavior. This seems to point to a bug in Weld
where some information coming from the old annotated type for a superclass (BeanOne) is
used for a subclass (BeanTwo). This is not what the spec says should happen: a CDI
implementation should only take into account the last annotated type for the subclass as
set by the extension.
Changes made to a superclass's AnnotatedType by extensions not
taken into account while sending ProcessAnnotatedType events pertaining to the subclass
------------------------------------------------------------------------------------------------------------------------------------------------------
Key: WELD-705
URL:
https://jira.jboss.org/browse/WELD-705
Project: Weld
Issue Type: Bug
Components: Bootstrap and Metamodel API
Affects Versions: 1.1.0.Beta1
Environment: Jersey extension in GlassFish faces this issue
Reporter: Sivakumar Thyagarajan
Fix For: 1.1.0.Beta2
Attachments: WebApplication1.tgz
It appears that Weld does not take into account changes made to a superclass's
AnnotatedType by extensions, when sending ProcessAnnotatedType events pertaining to the
subclass.
Please find attached a netbeans project that demonstrates the problem. It is a web app
containing a CDI extension that patches the annotated types it sees to remove all their
fields.
BeanOne has one field:
@Inject BeanManager beanManager;
BeanTwo extends BeanOne and doesn't add any fields.
There are no other injection points. The portable extensions patches the annotated type
for BeanOne and removes the BeanManager injection point. However on execution, this
output appears in the server log: (all the diagnostic output is at warning level...)
===
WARNING: Handling BeforeBeanDiscovery event
WARNING: Handling ProcessAnnotatedType event for beans.BeanOne
WARNING: type has 0 fields
WARNING: replaced annotated type for class beans.BeanOne
WARNING: Handling ProcessAnnotatedType event for beans.BeanTwo
WARNING: type has 0 fields
WARNING: replaced annotated type for class beans.BeanTwo
WARNING: Handling ProcessManagedBean event for beans.BeanTwo
WARNING: found injection point interface javax.enterprise.inject.spi.BeanManager
@javax.enterprise.inject.Default()
WARNING: Handling ProcessManagedBean event for beans.BeanOne
===
I.e. in BeanOne the field has been correctly nuked, but it comes back in BeanTwo.
Weld may be holding a reference to the old AnnotatedType for BeanOne as part of its
internal representation for BeanTwo and uses that instead of the replacement provided by
the extension. Since annotated types are self-contained, so Weld should not even look at
BeanOne at that point.
The same behavior can be observed on both GF 3.0.1 (=WELD-000900 1.0.1 (SP3)) and GF
3.1-b16 (=WELD-000900 1.1.0.01 (glassfish)).
A glassfish issue tracking this Jersey extension problem is at
https://glassfish.dev.java.net/issues/show_bug.cgi?id=13132
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira