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

The state gets reconstructed twice.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.1-SNAPSHOT
    • 1.2.2
    • None
    • None

    Description

      As the topic suggests, the state gets reconstructed twice during the Restore View phase. State reconstruction consists of decoding, decrypting and decompressing (assuming that MyFaces has been configured to do so) the given state (i.e. the "javax.faces.ViewState" request parameter) so it shouldn't be done more often than necessary. For a better understanding of this issue, I'll describe the call hierarchy (simplified):

      ///

      // myfaces/core/branches/1_2_1/impl/org/apache/myfaces/application/jsp/JspStateManagerImpl.java

      public UIViewRoot restoreView(FacesContext context, String viewId, String renderKitId) {
      ...
      if (isSavingStateInClient(context))

      { ... state = responseStateManager.getState(context, viewId); }

      ...
      }

      // myfaces/core/branches/1_2_1/api/javax/faces/render/ResponseStateManager.java

      public Object getState(FacesContext context, String viewId) {
      Object[] structureAndState = new Object[2];
      structureAndState[0] = getTreeStructureToRestore(context, viewId);
      structureAndState[1] = getComponentStateToRestore(context);
      return structureAndState;
      }

      // myfaces/core/branches/1_2_1/impl/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java

      public Object getTreeStructureToRestore(FacesContext facesContext, String viewId) {
      ...
      Object encodedState = requestParameterMap.get("javax.faces.ViewState");
      Object[] savedState = (Object[]) StateUtils.reconstruct((String) encodedState, ...);
      ...
      return savedState[TREE_PARAM];
      }

      public Object getComponentStateToRestore(FacesContext facesContext) {
      ...
      Object encodedState = requestParameterMap.get("javax.faces.ViewState");
      Object[] savedState = (Object[]) StateUtils.reconstruct((String) encodedState, ...);
      ...
      return savedState[STATE_PARAM];
      }

      \\\

      One possible solution (without breaking backward compatibility) is to override javax.faces.render.ResponseStateManager#getState(FacesContext, String) and that's exactly what I've done. I've tested my patch with the MyFaces Tomahawk examples on my notebook (Ubuntu 7.04, AMD Turion 1.80 GHz, 1.5 GB DDR). Additionally, I'll attach a Apache JMeter test configuration and results of this test using a local Jetty server. I'd appreciate someone backing up my test results.

      Attachments

        1. tests.zip
          11 kB
          Bernhard Huemer
        2. MYFACES-1701.patch
          4 kB
          Bernhard Huemer

        Activity

          People

            mmarinschek Martin Marinschek
            bhuemer Bernhard Huemer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: