commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r295107 - in /jakarta/commons/proper/beanutils/trunk/src: java/org/apache/commons/beanutils/LazyDynaBean.java test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java
Date Wed, 05 Oct 2005 20:36:09 GMT
Author: niallp
Date: Wed Oct  5 13:35:31 2005
New Revision: 295107

URL: http://svn.apache.org/viewcvs?rev=295107&view=rev
Log:
Fix Bug 36940 - don't try and instantiate properties of type Object.class - reported by Roi
Ares.

Modified:
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java
    jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java?rev=295107&r1=295106&r2=295107&view=diff
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java
Wed Oct  5 13:35:31 2005
@@ -587,6 +587,10 @@
      */
     protected Object createProperty(String name, Class type) {
 
+        if (type == Object.class) {
+            return null;
+        }
+
         // Create Lists, arrays or DynaBeans
         if (type.isArray() || List.class.isAssignableFrom(type)) {
             return createIndexedProperty(name, type);
@@ -728,7 +732,7 @@
     }
 
     /**
-     * Create a new Instance of a 'Primitive' Property
+     * Create a new Instance of a <code>java.lang.Number</code> Property.
      */
     protected Object createNumberProperty(String name, Class type) {
 
@@ -737,13 +741,18 @@
     }
 
     /**
-     * Create a new Instance of a 'Mapped' Property
+     * Create a new Instance of other Property types
      */
     protected Object createOtherProperty(String name, Class type) {
 
-        if (type == String.class || type == Boolean.class ||
-            type == Character.class || Date.class.isAssignableFrom(type)) {
+        if (type == Object.class    ||
+            type == String.class    ||
+            type == Boolean.class   ||
+            type == Character.class ||
+            Date.class.isAssignableFrom(type)) {
+
             return null;
+
         }
 
         try {

Modified: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java?rev=295107&r1=295106&r2=295107&view=diff
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java
Wed Oct  5 13:35:31 2005
@@ -116,6 +116,21 @@
     }
 
     /**
+     * Test Getting/Setting a 'null' Property
+     */
+    public void testNullProperty() {
+
+        // Check the property & value doesn't exist
+        assertNull("Check Property doesn't exist", dynaClass.getDynaProperty(testProperty));
+        assertNull("Check Value is null", bean.get(testProperty));
+
+        // Set a new property to null
+        bean.set(testProperty, null);
+        assertNull("Check Value is still null", bean.get(testProperty));
+
+    }
+
+    /**
      * Test Setting a Simple Property when MutableDynaClass is set to restricted
      */
     public void testSimplePropertyRestricted() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message