javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2508

CompositeComponentAttributeELResolver$ExpressionEvalMap caches FacesContext and fails in Portlet bridge renderRequest because cached FacesContext is released

    Details

      Description

      With Portlet 2 bridge two distinct instances of FacesContext are used for the two Portlet phases (request processing, response rendering). Now since FacesContext is cached in CompositeComponentAttributeELResolver$ExpressionEvalMap and as it seems the ELResolver's are reused by the Portlet Bridge for the two phases, during render response an already released FacesContext instance is causing:

      	java.lang.IllegalStateException
      	at com.sun.faces.context.FacesContextImpl.assertNotReleased(FacesContextImpl.java:655)
      	at com.sun.faces.context.FacesContextImpl.getELContext(FacesContextImpl.java:250)
      	at javax.faces.context.FacesContextWrapper.getELContext(FacesContextWrapper.java:341)
      	at com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.get(CompositeComponentAttributesELResolver.java:349)
      	at javax.el.MapELResolver.getValue(MapELResolver.java:164)
      	.... 
      

      To make this save, the cached FacesContext should be queried for it's release state and in case it's released re-cache the current FacesContext.getCurrentInstance() to make this Portlet save.

      1. changebundle.txt
        8 kB
        Manfred Riem
      2. changebundle.txt
        1 kB
        Hanspeter Duennenberger
      3. Exception in CompositeComponentAttributeELResolver in Portlet render phase.txt
        13 kB
        Hanspeter Duennenberger

        Activity

        Hide
        Hanspeter Duennenberger added a comment -

        Proposed change with re-caching FacesContext when the currently cached was released before.

        Show
        Hanspeter Duennenberger added a comment - Proposed change with re-caching FacesContext when the currently cached was released before.
        Hide
        Hanspeter Duennenberger added a comment -

        successfully run test.with.container.refresh with this change both on trunk and 2_1X branch.

        Maybe some tests with mocking the two Portlet Phase with separate FacesContext instances would be nice - are there already tests with mock-portlet setup? Manfred, any tip?

        Show
        Hanspeter Duennenberger added a comment - successfully run test.with.container.refresh with this change both on trunk and 2_1X branch. Maybe some tests with mocking the two Portlet Phase with separate FacesContext instances would be nice - are there already tests with mock-portlet setup? Manfred, any tip?
        Hide
        Hanspeter Duennenberger added a comment -

        Tried to create a JUnit test to cover this, but failed because setting up a test to let CompositeComponentAttributeELResolver access the FacesContext instance stored in the private inner class was getting too complicated.

        I made a Mojarra build containing this fix and let the project with Portal setup that discovered this problem verify the fix - theyr problem was fixed with this.

        Show
        Hanspeter Duennenberger added a comment - Tried to create a JUnit test to cover this, but failed because setting up a test to let CompositeComponentAttributeELResolver access the FacesContext instance stored in the private inner class was getting too complicated. I made a Mojarra build containing this fix and let the project with Portal setup that discovered this problem verify the fix - theyr problem was fixed with this.
        Hide
        Manfred Riem added a comment -

        Hanspeter, can you include the entire stacktrace? I want to investigate a bit further on this issue. Thanks!

        Show
        Manfred Riem added a comment - Hanspeter, can you include the entire stacktrace? I want to investigate a bit further on this issue. Thanks!
        Hide
        Hanspeter Duennenberger added a comment -

        Attached full stacktrace as requested by Manfred.

        Show
        Hanspeter Duennenberger added a comment - Attached full stacktrace as requested by Manfred.
        Hide
        Hanspeter Duennenberger added a comment -

        Changed the fix to not use FacesContext.getCurrentInstance() but update FacesContext in ExpressionEvalMap from the method getEvalMapFor() that is always used to deliver ExpressionEvalMap.

        Show
        Hanspeter Duennenberger added a comment - Changed the fix to not use FacesContext.getCurrentInstance() but update FacesContext in ExpressionEvalMap from the method getEvalMapFor() that is always used to deliver ExpressionEvalMap.
        Hide
        Manfred Riem added a comment -

        Applied to 2.1 branch,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2508, r=rogerk, fixes CompositeComponentAttributeELResolver$ExpressionEvalMap caches FacesContext and fails in Portlet bridge renderRequest because cached FacesContext is released."
        Sending jsf-ri\src\main\java\com\sun\faces\el\CompositeComponentAttributesELResolver.java
        Adding test\unit\src\test\java\com\sun\faces\el
        Adding test\unit\src\test\java\com\sun\faces\el\CompositeComponentAttributesELResolverTest.java
        Transmitting file data ..
        Committed revision 10607.

        Show
        Manfred Riem added a comment - Applied to 2.1 branch, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2508 , r=rogerk, fixes CompositeComponentAttributeELResolver$ExpressionEvalMap caches FacesContext and fails in Portlet bridge renderRequest because cached FacesContext is released." Sending jsf-ri\src\main\java\com\sun\faces\el\CompositeComponentAttributesELResolver.java Adding test\unit\src\test\java\com\sun\faces\el Adding test\unit\src\test\java\com\sun\faces\el\CompositeComponentAttributesELResolverTest.java Transmitting file data .. Committed revision 10607.
        Hide
        Manfred Riem added a comment -

        Applied to 2.2 trunk,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2508, r=rogerk, fixes CompositeComponentAttributeELResolver$ExpressionEvalMap caches FacesContext and fails in Portlet bridge renderRequest because cached FacesContext is released."
        Sending jsf-ri\src\main\java\com\sun\faces\el\CompositeComponentAttributesELResolver.java
        Transmitting file data .
        Committed revision 10608.

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2508, r=rogerk, fixes CompositeComponentAttributeELResolver$ExpressionEvalMap caches FacesContext and fails in Portlet bridge renderRequest because cached FacesContext is released."
        Adding test\unit\src\test\java\com\sun\faces\el
        Adding test\unit\src\test\java\com\sun\faces\el\CompositeComponentAttributesELResolverTest.java
        Transmitting file data .
        Committed revision 10609.

        Show
        Manfred Riem added a comment - Applied to 2.2 trunk, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2508 , r=rogerk, fixes CompositeComponentAttributeELResolver$ExpressionEvalMap caches FacesContext and fails in Portlet bridge renderRequest because cached FacesContext is released." Sending jsf-ri\src\main\java\com\sun\faces\el\CompositeComponentAttributesELResolver.java Transmitting file data . Committed revision 10608. svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2508 , r=rogerk, fixes CompositeComponentAttributeELResolver$ExpressionEvalMap caches FacesContext and fails in Portlet bridge renderRequest because cached FacesContext is released." Adding test\unit\src\test\java\com\sun\faces\el Adding test\unit\src\test\java\com\sun\faces\el\CompositeComponentAttributesELResolverTest.java Transmitting file data . Committed revision 10609.
        Hide
        Manfred Riem added a comment -

        Hanspeter, thanks for the bugfix!

        Show
        Manfred Riem added a comment - Hanspeter, thanks for the bugfix!

          People

          • Assignee:
            Manfred Riem
            Reporter:
            Hanspeter Duennenberger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: