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

Actions invoked with <s:action..> gets actionErrors copied from main action

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.13, 2.1.2
    • 2.2.1
    • Core Interceptors
    • None

    Description

      If I invoke an action from a JSP with <s:action..>, that action will get actionErrors copied from the first action.
      This is done by ChainingInterceptor, unless the first action implements Unchainable.
      Actions included with <s:action..> should be independent of the page they are included from, this is not the same as using resultType 'chain'.
      Example:

      FooAction:
      public class FooAction extends ActionSupport {
      public String execute()

      { addActionError("an error from FooAction"); return SUCCESS; }

      }

      foo.jsp:
      <s:action name="bar"/>

      BarAction:
      public class BarAction extends ActionSupport{
      }

      struts.xml:
      <action name="foo" class="test.FooAction">
      <result>/jsp/foo.jsp</result>
      </action>
      <action name="bar" class="test.BarAction">
      <result>/jsp/bar.jsp</result>
      </action>

      When going to /foo.action then BarAction is never invoked because:
      1) FooAction adds actionError
      2) foo.jsp is displayed
      3) foo.jsp invokes BarAction with <s:action..> tag
      4) ChainingInterceptor intercepts BarAction and copies actionErrors from FooAction to BarAction
      5) DefaultWorkflowInterceptor intercepts BarAction and since BarAction now has actionErrors, it stops the invocation and returns "input"
      6) There is no "input" result defined for BarAction, which leads to Exception

      This is the line in ChainingInterceptor that copies the actionErrors:
      reflectionProvider.copy(o, invocation.getAction(), ctxMap, excludes, includes);
      This shouldn't be done in the case of a <s:action..>, only for resultType 'chain'

      I have verified that this is still an issue in the latest svn version of 2.1.3 (rev 701674).

      Attachments

        1. WW-2869.patch
          5 kB
          Lukasz Lenart
        2. test.zip
          12 kB
          Ronny Løvtangen

        Activity

          People

            lukaszlenart Lukasz Lenart
            ronnylovtangen Ronny Løvtangen
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: