javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2471

FaceletPartialStateManagementStrategy#saveDynamicActions() throws NPE during postback when UIViewRoot#removeComponentResource() is during preRenderView performed on a @ResourceDependency

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.11
    • Fix Version/s: 2.1.12, 2.2.0-m05
    • Component/s: state saving
    • Labels:
      None
    • Environment:

      Mojarra 2.1.11

      Description

      Since Mojarra 2.1.11, the FaceletPartialStateManagementStrategy#saveDynamicActions() throws a NullPointerException during postback when UIViewRoot#removeComponentResource() is during preRenderView performed on a @ResourceDependency. This is regardless of whether the postback is performed by ajax or not.

      Here's the relevant part of the stacktrace

      java.lang.NullPointerException
      	at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.saveDynamicActions(FaceletPartialStateManagementStrategy.java:426)
      	at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.saveView(FaceletPartialStateManagementStrategy.java:491)
      	at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:89)
      	at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225)
      	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:441)
      	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
      	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
      

      According to the source, the component is absent in the componentMap, but its client ID is still present in actions. It seems that the componentMap and actions are somewhere getting out of sync. Based on debugging, I believe that the restoreDynamicRemove() method should somehow prevent the ComponentStruct from being added to the dynamic actions map whenever the child is null. Otherwise just a simple nullcheck on component inside saveDynamicActions() method should also fix it.

      This affects the OmniFaces CombinedResourceHandler. It worked fine on Mojarra 2.1.10 and older.

        Issue Links

          Activity

          Hide
          Manfred Riem added a comment -

          Logging in Development mode will be done because even though the component should never be null at that point it clearly is. Note the fix implemented will give you back the behavior of 2.1.10 for which you stated that it was working. The actual underlying problem has been identified and will be addressed in a separate issue.

          Show
          Manfred Riem added a comment - Logging in Development mode will be done because even though the component should never be null at that point it clearly is. Note the fix implemented will give you back the behavior of 2.1.10 for which you stated that it was working. The actual underlying problem has been identified and will be addressed in a separate issue.
          Hide
          Manfred Riem added a comment -

          Applied to 2.1 branch,

          svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2471, r=rogerk, Make sure that if we cannot find the component associated with the dynamic action that we let the user know by logging it, but we do want to continue."
          Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletPartialStateManagementStrategy.java
          Adding test\agnostic\dynamic\src\main\java\com\sun\faces\test\agnostic\dynamic\Issue2471Bean.java
          Adding test\agnostic\dynamic\src\main\java\com\sun\faces\test\agnostic\dynamic\Issue2471Component.java
          Adding test\agnostic\dynamic\src\main\webapp\WEB-INF\issue2471.taglib.xml
          Sending test\agnostic\dynamic\src\main\webapp\WEB-INF\web.xml
          Adding test\agnostic\dynamic\src\main\webapp\issue2471.xhtml
          Adding test\agnostic\dynamic\src\main\webapp\resources
          Adding test\agnostic\dynamic\src\main\webapp\resources\issue2471.js
          Adding test\agnostic\dynamic\src\test\java\com\sun\faces\test\agnostic\dynamic\Issue2471IT.java
          Transmitting file data ........
          Committed revision 10345.

          Show
          Manfred Riem added a comment - Applied to 2.1 branch, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2471 , r=rogerk, Make sure that if we cannot find the component associated with the dynamic action that we let the user know by logging it, but we do want to continue." Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletPartialStateManagementStrategy.java Adding test\agnostic\dynamic\src\main\java\com\sun\faces\test\agnostic\dynamic\Issue2471Bean.java Adding test\agnostic\dynamic\src\main\java\com\sun\faces\test\agnostic\dynamic\Issue2471Component.java Adding test\agnostic\dynamic\src\main\webapp\WEB-INF\issue2471.taglib.xml Sending test\agnostic\dynamic\src\main\webapp\WEB-INF\web.xml Adding test\agnostic\dynamic\src\main\webapp\issue2471.xhtml Adding test\agnostic\dynamic\src\main\webapp\resources Adding test\agnostic\dynamic\src\main\webapp\resources\issue2471.js Adding test\agnostic\dynamic\src\test\java\com\sun\faces\test\agnostic\dynamic\Issue2471IT.java Transmitting file data ........ Committed revision 10345.
          Hide
          Manfred Riem added a comment - - edited

          Applied to 2.2 trunk,

          svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2471, r=rogerk, Make sure that if we cannot find the component associated with the dynamic action that we let the user know by logging it, but we do want to continue."
          Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletPartialStateManagementStrategy.java
          Adding test\agnostic\dynamic\src\main\java\com\sun\faces\test\agnostic\dynamic\Issue2471Bean.java
          Adding test\agnostic\dynamic\src\main\java\com\sun\faces\test\agnostic\dynamic\Issue2471Component.java
          Adding test\agnostic\dynamic\src\main\webapp\WEB-INF\issue2471.taglib.xml
          Sending test\agnostic\dynamic\src\main\webapp\WEB-INF\web.xml
          Adding test\agnostic\dynamic\src\main\webapp\issue2471.xhtml
          Adding test\agnostic\dynamic\src\main\webapp\resources
          Adding test\agnostic\dynamic\src\main\webapp\resources\issue2471.js
          Adding test\agnostic\dynamic\src\test\java\com\sun\faces\test\agnostic\dynamic\Issue2471IT.java
          Transmitting file data ........
          Committed revision 10346.

          Show
          Manfred Riem added a comment - - edited Applied to 2.2 trunk, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2471 , r=rogerk, Make sure that if we cannot find the component associated with the dynamic action that we let the user know by logging it, but we do want to continue." Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletPartialStateManagementStrategy.java Adding test\agnostic\dynamic\src\main\java\com\sun\faces\test\agnostic\dynamic\Issue2471Bean.java Adding test\agnostic\dynamic\src\main\java\com\sun\faces\test\agnostic\dynamic\Issue2471Component.java Adding test\agnostic\dynamic\src\main\webapp\WEB-INF\issue2471.taglib.xml Sending test\agnostic\dynamic\src\main\webapp\WEB-INF\web.xml Adding test\agnostic\dynamic\src\main\webapp\issue2471.xhtml Adding test\agnostic\dynamic\src\main\webapp\resources Adding test\agnostic\dynamic\src\main\webapp\resources\issue2471.js Adding test\agnostic\dynamic\src\test\java\com\sun\faces\test\agnostic\dynamic\Issue2471IT.java Transmitting file data ........ Committed revision 10346.
          Hide
          Manfred Riem added a comment -

          Same logic needs to be applied for FSS.

          Applied to 2.1 branch,

          svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2471, r=rogerk, Make sure that if we cannot find the component associated with the dynamic action that we let the user know by logging it, but we do want to continue."
          Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletFullStateManagementStrategy.java
          Sending test\agnostic\dynamic\src\test\java\com\sun\faces\test\agnostic\dynamic\Issue2471IT.java
          Transmitting file data ..
          Committed revision 10351.

          Show
          Manfred Riem added a comment - Same logic needs to be applied for FSS. Applied to 2.1 branch, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2471 , r=rogerk, Make sure that if we cannot find the component associated with the dynamic action that we let the user know by logging it, but we do want to continue." Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletFullStateManagementStrategy.java Sending test\agnostic\dynamic\src\test\java\com\sun\faces\test\agnostic\dynamic\Issue2471IT.java Transmitting file data .. Committed revision 10351.
          Hide
          Manfred Riem added a comment -

          Same logic needs to be applied for FSS.

          Applied to 2.2 trunk,

          svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2471, r=rogerk, Make sure that if we cannot find the component associated with the dynamic action that we let the user know by logging it, but we do want to continue."
          Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletFullStateManagementStrategy.java
          Sending test\agnostic\dynamic\src\test\java\com\sun\faces\test\agnostic\dynamic\Issue2471IT.java
          Transmitting file data ..
          Committed revision 10352.

          Show
          Manfred Riem added a comment - Same logic needs to be applied for FSS. Applied to 2.2 trunk, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2471 , r=rogerk, Make sure that if we cannot find the component associated with the dynamic action that we let the user know by logging it, but we do want to continue." Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletFullStateManagementStrategy.java Sending test\agnostic\dynamic\src\test\java\com\sun\faces\test\agnostic\dynamic\Issue2471IT.java Transmitting file data .. Committed revision 10352.

            People

            • Assignee:
              Manfred Riem
              Reporter:
              balusc
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: