You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "gubiao (Jira)" <ji...@apache.org> on 2022/06/18 04:43:00 UTC

[jira] [Created] (WW-5195) Dispatcher: Infinite loop with dispatcher FORWARD

gubiao created WW-5195:
--------------------------

             Summary: Dispatcher: Infinite loop with dispatcher FORWARD
                 Key: WW-5195
                 URL: https://issues.apache.org/jira/browse/WW-5195
             Project: Struts 2
          Issue Type: Bug
          Components: Core, Core Actions
    Affects Versions: 6.0.0
            Reporter: gubiao


*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|https://github.com/apache/struts/pull/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?

 



--
This message was sent by Atlassian Jira
(v8.20.7#820007)