Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 28F66200BB7 for ; Wed, 9 Nov 2016 23:12:31 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 277D3160AFA; Wed, 9 Nov 2016 22:12:31 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6F66D160AEB for ; Wed, 9 Nov 2016 23:12:30 +0100 (CET) Received: (qmail 98458 invoked by uid 500); 9 Nov 2016 22:12:29 -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 98449 invoked by uid 99); 9 Nov 2016 22:12:29 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2016 22:12:29 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 3C52918819F for ; Wed, 9 Nov 2016 22:12:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id xWOad3ojgoLI for ; Wed, 9 Nov 2016 22:12:28 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 8E82D5F1B8 for ; Wed, 9 Nov 2016 22:12:27 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A04B7E010F for ; Wed, 9 Nov 2016 22:11:56 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id A00FF3A18C6 for ; Wed, 9 Nov 2016 22:11:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1769021 - in /velocity/engine/trunk/velocity-engine-core/src: main/java/org/apache/velocity/util/introspection/MethodMap.java test/java/org/apache/velocity/test/util/introspection/UberspectImplTestCase.java Date: Wed, 09 Nov 2016 22:11:56 -0000 To: commits@velocity.apache.org From: cbrisson@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20161109221156.A00FF3A18C6@svn01-us-west.apache.org> archived-at: Wed, 09 Nov 2016 22:12:31 -0000 Author: cbrisson Date: Wed Nov 9 22:11:56 2016 New Revision: 1769021 URL: http://svn.apache.org/viewvc?rev=1769021&view=rev Log: [engine] fix an introspection bug for null argument (and add corresponding test case) Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/UberspectImplTestCase.java Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java?rev=1769021&r1=1769020&r2=1769021&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java Wed Nov 9 22:11:56 2016 @@ -462,6 +462,7 @@ public class MethodMap return false; } } + return true; } else if (methodArgs.length > 0) // more arguments given than the method accepts; check for varargs { @@ -490,9 +491,9 @@ public class MethodMap return false; } } + return true; } - - return true; + return false; } /** Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/UberspectImplTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/UberspectImplTestCase.java?rev=1769021&r1=1769020&r2=1769021&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/UberspectImplTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/UberspectImplTestCase.java Wed Nov 9 22:11:56 2016 @@ -126,4 +126,32 @@ public class UberspectImplTestCase exten return Arrays.asList("1", "2", "3").iterator(); } } + + public class OverloadedMethods + { + public String foo() { return "foo0"; } + public String foo(String arg1) { return "foo1"; } + public String foo(String arg1, String arg2) { return "foo2"; } + } + + public void testOverloadedMethods() + { + VelocityContext context = new VelocityContext(); + context.put("over", new OverloadedMethods()); + StringWriter writer = new StringWriter(); + Velocity.evaluate(context, writer, "test", "$over.foo()"); + assertEquals(writer.toString(), "foo0"); + writer = new StringWriter(); + Velocity.evaluate(context, writer, "test", "$over.foo('a')"); + assertEquals(writer.toString(), "foo1"); + writer = new StringWriter(); + Velocity.evaluate(context, writer, "test", "$over.foo($null)"); + assertEquals(writer.toString(), "foo1"); + writer = new StringWriter(); + Velocity.evaluate(context, writer, "test", "$over.foo('a', 'b')"); + assertEquals(writer.toString(), "foo2"); + writer = new StringWriter(); + Velocity.evaluate(context, writer, "test", "$over.foo('a', $null)"); + assertEquals(writer.toString(), "foo2"); + } }