Commits

musachy  committed 74b30a5

WW-3306 Null value accepted from action property, but not model property when throwExceptionOnFailure=true

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@2074e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits e7219dc

Comments (0)

Files changed (4)

File core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java

                     // if there is a nested property (indicated by a dot), chop it off so we can look for method name
                     String rawProperty = (property.contains(".")) ? property.substring(0, property.indexOf(".")) : property;
                     String methodToLookFor = "get" + rawProperty.substring(0, 1).toUpperCase() + rawProperty.substring(1);
-                    Method[] methods = pd.getPropertyType().getDeclaredMethods();
+                    Method[] methods = pd.getPropertyType().getMethods();
                     for (Method method : methods) {
                         if (method.getName().equals(methodToLookFor)) {
                             availableProperties.add(name + "." + rawProperty);

File core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java

         }
     }
 
+    public void testFailOnErrorOnInheritedProperties() {
+        //this shuld not fail as the property is defined on a parent class
+        OgnlValueStack vs = createValueStack();
+
+        Foo foo = new Foo();
+        BarJunior barjr = new BarJunior();
+        foo.setBarJunior(barjr);
+        vs.push(foo);
+
+        assertNull(barjr.getTitle());
+        vs.findValue("barJunior.title", true);
+    }
+
+     public void testFailOnErrorOnInheritedPropertiesWithMethods() {
+        //this shuld not fail as the property is defined on a parent class
+        /*OgnlValueStack vs = createValueStack();
+
+        Foo foo = new Foo();
+        BarJunior barjr = new BarJunior();
+        foo.setBarJunior(barjr);
+        vs.push(foo);
+
+        assertNull(barjr.getTitle());
+        vs.findValue("getBarJunior().title", true);*/
+    }
+
     public void testFailOnMissingProperty() {
         OgnlValueStack vs = createValueStack();
 

File core/src/test/java/com/opensymphony/xwork2/util/BarJunior.java

+package com.opensymphony.xwork2.util;
+
+public class BarJunior extends Bar {
+}

File core/src/test/java/com/opensymphony/xwork2/util/Foo.java

     int number;
     long aLong;
     Calendar calendar;
+    BarJunior barJunior;
+
+    public BarJunior getBarJunior() {
+        return barJunior;
+    }
+
+    public void setBarJunior(BarJunior barJunior) {
+        this.barJunior = barJunior;
+    }
 
     public void setALong(long aLong) {
         this.aLong = aLong;