velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r711703 - in /velocity/engine/trunk/src: java/org/apache/velocity/util/introspection/UberspectImpl.java test/org/apache/velocity/test/VarargMethodsTestCase.java
Date Wed, 05 Nov 2008 21:26:40 GMT
Author: nbubna
Date: Wed Nov  5 13:26:40 2008
New Revision: 711703

URL: http://svn.apache.org/viewvc?rev=711703&view=rev
Log:
VELOCITY-642 take more care in handling arrays passed to vararg methods

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/VarargMethodsTestCase.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java?rev=711703&r1=711702&r2=711703&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
Wed Nov  5 13:26:40 2008
@@ -437,8 +437,10 @@
             else if (actual.length == index + 1)
             {
                 // make sure the last arg is an array of the expected type
-                if (IntrospectionUtils.isMethodInvocationConvertible(type,
-                                                                     actual[index].getClass(),
+                Class argClass = actual[index].getClass();
+                if (!argClass.isArray() &&
+                    IntrospectionUtils.isMethodInvocationConvertible(type,
+                                                                     argClass,
                                                                      false))
                 {
                     // create a 1-length array to hold and replace the last param

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/VarargMethodsTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/VarargMethodsTestCase.java?rev=711703&r1=711702&r2=711703&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/VarargMethodsTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/VarargMethodsTestCase.java Wed
Nov  5 13:26:40 2008
@@ -19,6 +19,7 @@
  * under the License.    
  */
 
+import java.util.Arrays;
 import org.apache.velocity.VelocityContext;
 
 /**
@@ -109,6 +110,12 @@
         assertEvalEquals("noargs", "$nasty.test()");
     }
 
+    public void testPassingArrayToVarArgVelocity642()
+    {
+        assertEvalEquals("[one, two]", "$nasty.test642($strings)");
+        assertEvalEquals("[1, 2]", "#set( $list = [1..2] )$nasty.test642($list.toArray())");
+    }
+
 
 
     public static class NiceTool
@@ -192,6 +199,11 @@
             return "object,string";
         }
 
+        public String test642(Object[] array)
+        {
+            return Arrays.deepToString(array);
+        }
+
     }
 
 }



Mime
View raw message