[ 
https://issues.apache.org/jira/browse/WW-5190?focusedWorklogId=782249&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-782249
 ]

ASF GitHub Bot logged work on WW-5190:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Jun/22 06:24
            Start Date: 17/Jun/22 06:24
    Worklog Time Spent: 10m 
      Work Description: yasserzamani commented on code in PR #571:
URL: https://github.com/apache/struts/pull/571#discussion_r899800362


##########
core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java:
##########
@@ -656,6 +649,36 @@ public void serviceAction(HttpServletRequest request, 
HttpServletResponse respon
         }
     }
 
+    private ActionProxy prepareActionProxy(Map<String, Object> extraContext, 
String actionNamespace, String actionName, String actionMethod) {
+        ActionProxy proxy;
+        //check if we are probably in an async resuming
+        ActionInvocation invocation = 
ActionContext.getContext().getActionInvocation();
+        if (invocation == null || invocation.isExecuted()) {
+            LOG.trace("Creating a new action, namespace: {}, name: {}, method: 
{}", actionNamespace, actionName, actionMethod);
+            proxy = createActionProxy(actionNamespace, actionName, 
actionMethod, extraContext);
+        } else {
+            proxy = invocation.getProxy();
+            if (isSameAction(proxy, actionNamespace, actionName, 
actionMethod)) {
+                LOG.trace("Proxy: {} matches requested action, namespace: {}, 
name: {}, method: {} - reusing proxy", proxy, actionNamespace, actionName, 
actionMethod);
+            } else {
+                LOG.trace("Proxy: {} doesn't match action namespace: {}, name: 
{}, method: {} - creating new proxy", proxy, actionNamespace, actionName, 
actionMethod);
+                proxy = createActionProxy(actionNamespace, actionName, 
actionMethod, extraContext);

Review Comment:
   to avoid StackOverflowException, shouldn't this line go to if(isSame) 
statement instead of else statement? because I think StackOverflow happens when 
we forward to same action again and again, but the if statement is empty, 
doesn't do anything functional, just logs.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 782249)
    Time Spent: 0.5h  (was: 20m)

> StackOverflowError when dispatching to JSP
> ------------------------------------------
>
>                 Key: WW-5190
>                 URL: https://issues.apache.org/jira/browse/WW-5190
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 6.0.0
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 6.0.1
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> I am running a Spring Boot 2.7.0 (Latest) Tomcat embedded WAR + Spring 
> Security + Struts 6.0.0 Actions + JSP pages.  I started noticing a loop when 
> a Struts2 Action result type is a "dispatcher" with following repetitive 
> stack trace.  Then, a stack overflow is raised.
> {noformat}
> ...... repeated several times ......
>         at 
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:637) 
> ~[struts2-core-6.0.0.jar:6.0.0]
>         at 
> org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:79)
>  ~[struts2-core-6.0.0.jar:6.0.0]
>         at 
> org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:140)
>  ~[struts2-core-6.0.0.jar:6.0.0]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
>  ~[tomcat-embed-core-9.0.63.jar:9.0.63]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
>  ~[tomcat-embed-core-9.0.63.jar:9.0.63]
>         at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:111)
>  ~[spring-web-5.3.20.jar:5.3.20]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
>  ~[tomcat-embed-core-9.0.63.jar:9.0.63]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
>  ~[tomcat-embed-core-9.0.63.jar:9.0.63]
>         at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:111)
>  ~[spring-web-5.3.20.jar:5.3.20]
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
>  ~[tomcat-embed-core-9.0.63.jar:9.0.63]
> {noformat}



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

Reply via email to