You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2013/04/30 23:32:47 UTC
svn commit: r1477839 - in
/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors:
InstantiateTransformer.java InvokerTransformer.java
Author: tn
Date: Tue Apr 30 21:32:47 2013
New Revision: 1477839
URL: http://svn.apache.org/r1477839
Log:
[COLLECTIONS-453] Clone input parameters, add null check, final.
Modified:
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java?rev=1477839&r1=1477838&r2=1477839&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java Tue Apr 30 21:32:47 2013
@@ -60,7 +60,8 @@ public class InstantiateTransformer<T> i
* @param args the constructor arguments
* @return an instantiate transformer
*/
- public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(Class<?>[] paramTypes, Object[] args) {
+ public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(final Class<?>[] paramTypes,
+ final Object[] args) {
if (((paramTypes == null) && (args != null))
|| ((paramTypes != null) && (args == null))
|| ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) {
@@ -93,8 +94,8 @@ public class InstantiateTransformer<T> i
*/
public InstantiateTransformer(final Class<?>[] paramTypes, final Object[] args) {
super();
- iParamTypes = paramTypes.clone();
- iArgs = args.clone();
+ iParamTypes = paramTypes != null ? paramTypes.clone() : null;
+ iArgs = args != null ? args.clone() : null;
}
/**
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java?rev=1477839&r1=1477838&r2=1477839&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java Tue Apr 30 21:32:47 2013
@@ -67,8 +67,8 @@ public class InvokerTransformer<I, O> im
* @param args the arguments to pass to the method
* @return an invoker transformer
*/
- public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, Class<?>[] paramTypes,
- Object[] args) {
+ public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, final Class<?>[] paramTypes,
+ final Object[] args) {
if (methodName == null) {
throw new IllegalArgumentException("The method to invoke must not be null");
}
@@ -80,8 +80,6 @@ public class InvokerTransformer<I, O> im
if (paramTypes == null || paramTypes.length == 0) {
return new InvokerTransformer<I, O>(methodName);
} else {
- paramTypes = paramTypes.clone();
- args = args.clone();
return new InvokerTransformer<I, O>(methodName, paramTypes, args);
}
}
@@ -101,16 +99,18 @@ public class InvokerTransformer<I, O> im
/**
* Constructor that performs no validation.
* Use <code>invokerTransformer</code> if you want that.
+ * <p>
+ * Note: from 4.0, the input parameters will be cloned
*
* @param methodName the method to call
- * @param paramTypes the constructor parameter types, not cloned
- * @param args the constructor arguments, not cloned
+ * @param paramTypes the constructor parameter types
+ * @param args the constructor arguments
*/
public InvokerTransformer(final String methodName, final Class<?>[] paramTypes, final Object[] args) {
super();
iMethodName = methodName;
- iParamTypes = paramTypes;
- iArgs = args;
+ iParamTypes = paramTypes != null ? paramTypes.clone() : null;
+ iArgs = args != null ? args.clone() : null;
}
/**