commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1449456 - in /commons/proper/beanutils/trunk/src: changes/changes.xml main/java/org/apache/commons/beanutils/ConstructorUtils.java test/java/org/apache/commons/beanutils/ConstructorUtilsTestCase.java
Date Sun, 24 Feb 2013 11:29:04 GMT
Author: britter
Date: Sun Feb 24 11:29:04 2013
New Revision: 1449456

URL: http://svn.apache.org/r1449456
Log:
[BEANUTILS-426] - ConstructorUtils.invokeConstructor(Class klass, Object arg) throws NullPointerException
when arg==null

Modified:
    commons/proper/beanutils/trunk/src/changes/changes.xml
    commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
    commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ConstructorUtilsTestCase.java

Modified: commons/proper/beanutils/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/changes/changes.xml?rev=1449456&r1=1449455&r2=1449456&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/changes/changes.xml (original)
+++ commons/proper/beanutils/trunk/src/changes/changes.xml Sun Feb 24 11:29:04 2013
@@ -40,6 +40,10 @@ The <action> type attribute can be add,u
   <body>
 
     <release version="1.8.4" date="in SVN" description="Bug fix for 1.8.3">
+      <action dev="britter" type="fix" issue="BEANUTILS-426" >
+         ConstructorUtils.invokeConstructor(Class klass, Object arg) throws 
+         NullPointerException when arg==null
+      </action>
       <action dev="niallp" type="fix" issue="BEANUTILS-380" due-to="Brendan Nolan">
          BeanMap methods should initialize the root cause of exceptions that are thrown
          when running on JDK 1.4+

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java?rev=1449456&r1=1449455&r2=1449456&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
(original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
Sun Feb 24 11:29:04 2013
@@ -82,6 +82,9 @@ public class ConstructorUtils {
             InstantiationException {
 
         Object[] args = { arg };
+        if (arg == null) {
+            args = null;
+        }
         return invokeConstructor(klass, args);
     }
 

Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ConstructorUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ConstructorUtilsTestCase.java?rev=1449456&r1=1449455&r2=1449456&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ConstructorUtilsTestCase.java
(original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/ConstructorUtilsTestCase.java
Sun Feb 24 11:29:04 2013
@@ -88,6 +88,12 @@ public class ConstructorUtilsTestCase ex
         }
     }
 
+    public void testInvokeConstructorNull() throws Exception {
+        Object obj = ConstructorUtils.invokeConstructor(TestBean.class, (Object) null);
+        assertNotNull(obj);
+        assertTrue(obj instanceof TestBean);
+    }
+
     public void testInvokeConstructorWithArgArray() throws Exception {
         Object[] args = { new Float(17.3f), "TEST" };
         Object obj = ConstructorUtils.invokeConstructor(TestBean.class,args);



Mime
View raw message