Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-5195

Dispatcher: Infinite loop with dispatcher FORWARD

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 6.0.0
    • 6.0.3
    • Core, Core Actions
    • None

    Description

      Action a:

      public String a()
      
      {    
      
      request.getRequestDispatcher("/b.action").forward(request, response);    
      
      return null;
      
      }
      

       

      Action b:

      public String b()
      
      { ... }
      

       

      When the user calls /a.action, it is automatically forwarded to b.action. These codes work well in Struts 2.5.x version.

      After upgrading to the 6.0.0 version, code like the above will cause an infinite loop issue.

      In Struts 6.0.0, code like "actionA->forward->actionB" will cause infinite loop issue.

       

      This issue also exists when using ServletDispatcherResult to initiate a forward request:

      <result name="success" type="dispatcher">
          <param name="location">b.action</param>
      </result>
      

       

      This issue related to #179 pull request.

      https://github.com/apache/struts/pull/179/files#diff-a394bef2608163b6810c293626eb1356e3be43ec82f94fe6da881f0608a86547

       

      ActionInvocation invocation = ActionContext.getContext().getActionInvocation();
      if (invocation == null || invocation.isExecuted())
      
      { // *The code here doesn't handle the servlet forward case*    proxy=getContainer().getInstance(ActionProxyFactory.class).createActionProxy(namespace, name, method, extraContext, true, false); }
      
      else
      
      {     proxy=invocation.getProxy(); }
      

       

      Once this problem occurs, the jvm process consumes a lot of CPU resources, and there is no log to troubleshoot.

       

      I don't know much about how Struts internals work, is there any workaround other than delayed upgrade to Struts 6.x version?

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gubiao gubiao
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: