Commits

Anonymous committed f8c247a

Fixes OGNL-55.

ExpressionCompiler.shouldCast(Node) was returning true for ASTConst ...Obviousoly not correct.

  • Participants
  • Parent commits d24a4b4

Comments (0)

Files changed (5)

src/java/ognl/ASTMethod.java

 
                     Class prevType = context.getCurrentType();
 
+                    context.setCurrentObject(context.getRoot());
+                    context.setCurrentType(context.getRoot() != null ? context.getRoot().getClass() : null);
+                    context.setCurrentAccessor(null);
+                    context.setPreviousType(null);
+
                     Object value = _children[i].getValue(context, context.getRoot());
                     String parmString = _children[i].toSetSourceString(context, context.getRoot());
 

src/java/ognl/enhance/ExpressionCompiler.java

                 return false;
         }
 
+        if (ASTConst.class.isInstance(expression))
+            return false;
+
         return true;
     }
 

src/test/java/org/ognl/test/PropertyTest.java

             { ROOT, "nullObject || !readonly", Boolean.TRUE },
             { ROOT, "testDate == null ? '-' : @org.ognl.test.PropertyTest@DATETIME_FORMAT.format(testDate)", DATETIME_FORMAT.format(ROOT.getTestDate()) },
             { ROOT, "disabled ? 'disabled' : 'othernot'", "disabled" },
-            { BEAN, "two.getMessage(active ? 'ACT' : 'INA')", "[ACT]"} 
+            { BEAN, "two.getMessage(active ? 'ACT' : 'INA')", "[ACT]"},
+            { BEAN, "hasChildren('aaa')", Boolean.TRUE},
+            { BEAN, "two.hasChildren('aa')", Boolean.FALSE},
+            { BEAN, "two.hasChildren('a')", Boolean.FALSE}
     };
 
     public static String formatValue(int millis, boolean b1, boolean b2)

src/test/java/org/ognl/test/objects/BaseBean.java

     {
         return "[" + mes + "]";
     }
+
+    public boolean hasChildren(String name)
+    {
+        return name.length() > 2;
+    }
 }

src/test/java/org/ognl/test/objects/Two.java

     {
         return "[" + mes + "]";
     }
+
+    public boolean hasChildren(String name)
+    {
+        return name.length() > 2;
+    }
 }