commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1449876 - in /commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils: ConstructorUtils.java MethodUtils.java
Date Mon, 25 Feb 2013 20:37:28 GMT
Author: britter
Date: Mon Feb 25 20:37:28 2013
New Revision: 1449876

URL: http://svn.apache.org/r1449876
Log:
Invert conditional logic as discussed on the ML (http://markmail.org/message/psfzd3l7yaxx6n5v)

Modified:
    commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
    commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java

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=1449876&r1=1449875&r2=1449876&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
Mon Feb 25 20:37:28 2013
@@ -81,10 +81,7 @@ public class ConstructorUtils {
             InvocationTargetException,
             InstantiationException {
 
-        Object[] args = { arg };
-        if (arg == null) {
-            args = null;
-        }
+        Object[] args = toArray(arg);
         return invokeConstructor(klass, args);
     }
 
@@ -193,10 +190,7 @@ public class ConstructorUtils {
             InvocationTargetException,
             InstantiationException {
 
-        Object[] args = { arg };
-        if (arg == null) {
-            args = null;
-        }
+        Object[] args = toArray(arg);
         return invokeExactConstructor(klass, args);
     }
 
@@ -344,6 +338,14 @@ public class ConstructorUtils {
         return null;
     }
 
+    private static Object[] toArray(Object arg) {
+        Object[] args = null;
+        if (arg != null) {
+            args = new Object[] { arg };
+        }
+        return args;
+    }
+
     // -------------------------------------------------------- Private Methods
     /**
      * <p>Find an accessible constructor with compatible parameters.

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java?rev=1449876&r1=1449875&r2=1449876&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java
(original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java
Mon Feb 25 20:37:28 2013
@@ -671,9 +671,9 @@ public class MethodUtils {
 
 
     private static Object[] toArray(Object arg) {
-        Object[] args = {arg};
-        if (arg == null) {
-            args = null;
+        Object[] args = null;
+        if (arg != null) {
+            args = new Object[] { arg };
         }
         return args;
     }



Mime
View raw message