Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4047

@PreDestroy method not invokved on javax.faces.bean.ViewScoped beans on Session invalidation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.2.10
    • 2.2.11
    • JSR-344
    • None

    Description

      Consider the following scenario:

      Bean1:
      @Named
      @ViewScoped (javax.faces.view.ViewScoped)

      Bean2:
      @ManagedBean
      @ViewScoped (javax.faces.bean.ViewScoped)

      When the session is invalidated the org.apache.myfaces.cdi.impl.CDIManagedBeanHandlerImpl.onSessionDestroyed() method is invoked. Here, MyFaces destroys all of the javax.faces.view.ViewScoped @Named beans and @PreDestroy is invoked on these beans. However, the @ManagedBean /ViewScoped bean does not have its @PreDestroy invoked.

      I believe this is because the assumption was made that if an Application is CDI enabled it will contain all CDI @Named beans and not any @ManagedBeans. There is also the DefaultViewScopeHandler which is not yet implemented for "onSessionDestroyed" that would be used in the case when CDI is not enabled, that is when only @ManagedBeans are contained in the application.

      I believe it is possible to update the CDIManagedBeanHandlerImpl to be aware of the ViewScoped ManagedBeans and destroy them onSessionDestroy first by just getting the viewMap and iterating over the entries as we do when the PreDestroyViewMapEvent is processed.

      I'd like to use this issue to resolve the problem in CDIManagedBeanHandlerImpl as well as implement onSessionDestroy in DefaultViewScopeHandler.java

      Attachments

        1. myfaces-4047-with-cdi.patch
          8 kB
          Hank Ibell
        2. MYFACES-4047-2-UNTESTED-ONLY-DEFAULT-VIEWSCOPE.patch
          4 kB
          Leonardo Uribe
        3. myfaces-4047.patch
          4 kB
          Paul Nicolucci
        4. myfaces-4047.patch
          5 kB
          Hank Ibell

        Activity

          People

            lu4242 Leonardo Uribe
            paul.nicolucci Paul Nicolucci
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: