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

NullPointerException in OgnlTextParser.evaluate().

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.3.14
    • 2.3.14
    • Core Interceptors
    • None
    • Important

    Description

      In the latest code, lukaszlenart refactored some code. Using a recent build, I get the following error (relevant code follows).

      java.lang.NullPointerException
      	at com.opensymphony.xwork2.util.TextParseUtil$1.evaluate(TextParseUtil.java:161)
      	at com.opensymphony.xwork2.util.OgnlTextParser.evaluate(OgnlTextParser.java:50)
      	at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:172)
      	at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:127)
      	at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:71)
      	at org.apache.struts2.dispatcher.StrutsResultSupport.conditionalParse(StrutsResultSupport.java:198)
      	at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:185)
      	at org.apache.struts2.dispatcher.ServletRedirectResult.execute(ServletRedirectResult.java:161)
      	at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
      	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
      	at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
      

      The relevant source code is:

       
      +        ParsedValueEvaluator ognlEval = new ParsedValueEvaluator() {
      +            public Object evaluate(String parsedValue) {
      +                Object o = stack.findValue(parsedValue, asType);
      +                if (evaluator != null) {
      +                    o = evaluator.evaluate(o.toString());
                       }
      +                return o;
                   }
      -        }
      

      Appears as if there is an assumption that the stack.findValue() will always return a non-null value.

      Attachments

        Activity

          People

            lukaszlenart Lukasz Lenart
            xtianstone Christian Wolfgang Stone
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: