Uploaded image for project: 'Commons OGNL'
  1. Commons OGNL
  2. OGNL-121

Race condition in SimpleNode#evaluateGetValueBody(OgnlContext, Object)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.9
    • Fix Version/s: 2.7.2
    • Component/s: None
    • Labels:
      None
    • Flags:
      Patch

      Description

      SimpleNode#evaluateGetValueBody(OgnlContext, Object) might return null.

      I have a patch that resolves the issue for version 2.6.9. Same issue might be in the above vesions.

       
      
      Index: C:/User/Work/workspace/ognl/src/java/ognl/SimpleNode.java
      
      ===================================================================
      
      --- C:/User/Work/workspace/ognl/src/java/ognl/SimpleNode.java	(revision 139)
      
      +++ C:/User/Work/workspace/ognl/src/java/ognl/SimpleNode.java	(working copy)
      
      @@ -44,7 +44,7 @@
      
           protected OgnlParser    parser;
      
       
      
           private boolean         constantValueCalculated;
      
      -    private boolean         hasConstantValue;
      
      +    private volatile boolean hasConstantValue;
      
           private Object          constantValue;
      
       
      
           public SimpleNode(int i) {
      
      @@ -162,10 +162,11 @@
      
               context.setCurrentNode(this);
      
               if (!constantValueCalculated) {
      
                   constantValueCalculated = true;
      
      -            hasConstantValue = isConstant(context);
      
      -            if (hasConstantValue) {
      
      +            boolean constant = isConstant(context);
      
      +            if (constant) {
      
                       constantValue = getValueBody(context, source);
      
                   }
      
      +            hasConstantValue = constant;
      
               }
      
               return hasConstantValue ? constantValue : getValueBody(context, source);
      
           }
      
      

        Attachments

          Activity

            People

            • Assignee:
              jkuhnert Jesse Kuhnert
              Reporter:
              toshihiro.nakamura Toshihiro Nakamura
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: