[cdi-dev] [JBoss JIRA] (CDI-230) Clarify that some Scope constellations for producer fields result in non portable behaviour

Pete Muir (JIRA) jira-events at lists.jboss.org
Thu Aug 16 08:46:16 EDT 2012

    [ https://issues.jboss.org/browse/CDI-230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12711987#comment-12711987 ] 

Pete Muir commented on CDI-230:

I'm not sure it's non-portable, it's clear what the implementation of CDI will do in this case. It's just that a user needs to be aware they put their app in an inconsistent state by doing this. IOW we need to warn people to be aware of this.
> Clarify that some Scope constellations for producer fields result in non portable behaviour
> -------------------------------------------------------------------------------------------
>                 Key: CDI-230
>                 URL: https://issues.jboss.org/browse/CDI-230
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>          Components: Beans
>    Affects Versions: 1.1.EDR1
>            Reporter: Mark Struberg
>             Fix For: 1.1 (Proposed)
> We should add something like the following to the producer-field paragraph:
> "When a producer field produces a bean with a 'shorter' Lifecycle than the scope of the class the producer field is defined in, non-portable behaviour results."
> An example:
> {code}
> @ApplicationScoped
> public class ContainerBean {
>   @Produces @RequestScoped
>   Something something = new Something(1, 2, 3);
>   void throwAway(@Disposes Something sthg) {
>     sthg.destroyMe();
>   }
> }
> {code}
> The problem is that each request will take 'something' from the @ApplicationScoped ContainerBean. Thus all requests share the same contextual instance! Afer the first request ends, the disposal method 'throwAway' will destroy the information inside the variable 'something' and leaves it in a broken state for all other requests -> bang...

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 cdi-dev mailing list