Struts 2
  1. Struts 2
  2. WW-4066

Submitting form with parameters using brackets while devMode=true yields StringIndexOutOfBoundsException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.14
    • Fix Version/s: 2.3.16
    • Component/s: Core Actions
    • Labels:
      None

      Description

      Our BaseAction which extends ActionSupport overrides the addActionMessage() with the following:

      @Override
      public void addActionMessage(String message) {
        super.addActionMessage(getText(message));
      }
      

      With the above method in place during devMode=true, the following error stack trace occurs:

      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1871)
        at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:426)
        at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:362)
        at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:208)
        at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:123)
        at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:103)
        at com.setech.dw.common.web.BaseAction.addActionMessage(BaseAction.java:209)
        at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:337)
        at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:241)
      
      1. testcase.zip
        6.72 MB
        Chris Cranford
      2. ParametersInterceptor.java
        6 kB
        Johno Crawford

        Activity

        Chris Cranford created issue -
        Lukasz Lenart made changes -
        Field Original Value New Value
        Description Our BaseAction which extends ActionSupport overrides the addActionMessage() with the following:

        @Override
        public void addActionMessage(String message) {
          super.addActionMessage(getText(message));
        }

        With the above method in place during devMode=true, the following error stack trace occurs:

        java.lang.StringIndexOutOfBoundsException: String index out of range: -1
          at java.lang.String.substring(String.java:1871)
          at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:426)
          at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:362)
          at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:208)
          at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:123)
          at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:103)
          at com.setech.dw.common.web.BaseAction.addActionMessage(BaseAction.java:209)
          at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:337)
          at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:241)
        Our BaseAction which extends ActionSupport overrides the addActionMessage() with the following:

        {code:java}
        @Override
        public void addActionMessage(String message) {
          super.addActionMessage(getText(message));
        }
        {code}

        With the above method in place during devMode=true, the following error stack trace occurs:

        {noformat}
        java.lang.StringIndexOutOfBoundsException: String index out of range: -1
          at java.lang.String.substring(String.java:1871)
          at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:426)
          at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:362)
          at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:208)
          at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:123)
          at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:103)
          at com.setech.dw.common.web.BaseAction.addActionMessage(BaseAction.java:209)
          at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:337)
          at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:241)
        {noformat}
        Lukasz Lenart made changes -
        Fix Version/s 2.3.15 [ 12324267 ]
        Chris Cranford made changes -
        Attachment testcase.zip [ 12583665 ]
        Lukasz Lenart made changes -
        Assignee Lukasz Lenart [ lukaszlenart ]
        Lukasz Lenart made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Not A Problem [ 8 ]
        Lukasz Lenart made changes -
        Resolution Not A Problem [ 8 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.16 [ 12324546 ]
        Fix Version/s 2.3.15 [ 12324267 ]
        Lukasz Lenart made changes -
        Comment [ Just collecting what could potentially break backward compatibility:

        - silly change, just added {{e}} to have the full stacktrace (but for sure changed with wrong commit):
        http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java?r1=1439410&r2=1456961&diff_format=h ]
        Johno Crawford made changes -
        Attachment ParametersInterceptor.java [ 12609261 ]
        Lukasz Lenart made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Lukasz Lenart made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Lukasz Lenart
            Reporter:
            Chris Cranford
          • Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development