Return-Path: Delivered-To: apmail-velocity-commits-archive@locus.apache.org Received: (qmail 86854 invoked from network); 5 Nov 2008 21:27:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Nov 2008 21:27:31 -0000 Received: (qmail 91610 invoked by uid 500); 5 Nov 2008 21:27:38 -0000 Delivered-To: apmail-velocity-commits-archive@velocity.apache.org Received: (qmail 91586 invoked by uid 500); 5 Nov 2008 21:27:38 -0000 Mailing-List: contact commits-help@velocity.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@velocity.apache.org Delivered-To: mailing list commits@velocity.apache.org Received: (qmail 91577 invoked by uid 99); 5 Nov 2008 21:27:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Nov 2008 13:27:38 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Nov 2008 21:26:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F181323888A2; Wed, 5 Nov 2008 13:26:40 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@velocity.apache.org From: nbubna@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081105212640.F181323888A2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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); + } + } }