Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-230

Clarify that some Scope constellations for producer fields result in non portable behaviour

    XMLWordPrintable

Details

    • Clarification
    • Resolution: Won't Do
    • Major
    • None
    • 1.1.EDR
    • Beans
    • None

    Description

      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:

      @ApplicationScoped
      public class ContainerBean {
      
        @Produces @RequestScoped
        Something something = new Something(1, 2, 3);
      
        void throwAway(@Disposes Something sthg) {
          sthg.destroyMe();
        }
      }
      

      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...

      Attachments

        Activity

          People

            struberg Mark Struberg (Inactive)
            struberg Mark Struberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: