[weld-issues] [JBoss JIRA] Commented: (WELD-310) Producer called on Bean that is under construction

Nicklas Karlsson (JIRA) jira-events at lists.jboss.org
Sun Dec 6 17:23:30 EST 2009


    [ https://jira.jboss.org/jira/browse/WELD-310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12498487#action_12498487 ] 

Nicklas Karlsson commented on WELD-310:
---------------------------------------

I'm not sure if it's the same issue but I've seen the case where you have a 

   @Produces @FooDB @PersistenceContext private EntityManager db;
   @Inject @FooDB EntityManager fooDb;

in the same bean.

Debugging shows that injection goes OK but upon calling, the producer field line

            public T produce(CreationalContext<T> creationalContext)
            {
               // unwrap if we have a proxy
               return field.get(InterceptionUtils.getRawInstance(getReceiver(creationalContext)));
            }

still returns a proxy to the bean, resulting in a null product. The getReceiver has the following comment

      // This is a bit dangerous, as it means that producer methods can end of
      // executing on partially constructed instances. Also, it's not required
      // by the spec...

;-)



> Producer called on Bean that is under construction
> --------------------------------------------------
>
>                 Key: WELD-310
>                 URL: https://jira.jboss.org/jira/browse/WELD-310
>             Project: Weld
>          Issue Type: Bug
>          Components: Producers (Methods, Fields and Disposers)
>    Affects Versions: 1.0.0.GA
>            Reporter: Gavin King
>             Fix For: 1.0.1.CR1
>
>
> The following code results in a call to Foo.foo() for a bean that has not yet been fully constructed:
> class Bar {
>     @Inject void injectFoo(Foo foo) {}
>     @Produces Foo produceFoo() { return new Foo(); }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list