From commits-return-70217-archive-asf-public=cust-asf.ponee.io@commons.apache.org Fri Nov 1 17:14:00 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 97DE4180626 for ; Fri, 1 Nov 2019 18:14:00 +0100 (CET) Received: (qmail 99698 invoked by uid 500); 1 Nov 2019 17:13:59 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 99689 invoked by uid 99); 1 Nov 2019 17:13:59 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Nov 2019 17:13:59 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 7EC9C805E6; Fri, 1 Nov 2019 17:13:59 +0000 (UTC) Date: Fri, 01 Nov 2019 17:13:59 +0000 To: "commits@commons.apache.org" Subject: [commons-jexl] branch master updated: JEXL: potential (317) issue on method chaining ? MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <157262843946.20939.11529666827017821653@gitbox.apache.org> From: henrib@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: commons-jexl X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 911180be2e527cb42aa5839991ef0a5ada621d19 X-Git-Newrev: ddbe2c925cb076aeb28ed3ec77997ddf00872d00 X-Git-Rev: ddbe2c925cb076aeb28ed3ec77997ddf00872d00 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. henrib pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git The following commit(s) were added to refs/heads/master by this push: new ddbe2c9 JEXL: potential (317) issue on method chaining ? ddbe2c9 is described below commit ddbe2c925cb076aeb28ed3ec77997ddf00872d00 Author: Henri Biestro AuthorDate: Fri Nov 1 18:13:43 2019 +0100 JEXL: potential (317) issue on method chaining ? --- .../org/apache/commons/jexl3/Issues300Test.java | 40 +++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java index 9d84031..d2b45ec 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java @@ -169,7 +169,7 @@ public class Issues300Test { o = e.execute(null); Assert.assertEquals(2, o); } - + @Test public void testIssue306d() throws Exception { JexlEngine jexl = new JexlBuilder().safe(true).create(); @@ -179,7 +179,7 @@ public class Issues300Test { o = e.execute(null); Assert.assertEquals(2, o); } - + @Test public void testIssue309a() throws Exception { String src = "\n" @@ -238,7 +238,7 @@ public class Issues300Test { Assert.assertEquals(4, xerror.getInfo().getLine()); } } - + public static class VaContext extends MapContext { VaContext(Map vars) { super(vars); @@ -246,7 +246,7 @@ public class Issues300Test { public int cell(String... ms) { return ms.length == 0 ? 0 : ms.length; } - + public int cell(List l, String...ms) { return 42 + cell(ms); } @@ -271,28 +271,28 @@ public class Issues300Test { script = jexl.createScript("x.cell('1', '2')", "x"); result = script.execute(ctxt, Arrays.asList(10, 20)); Assert.assertEquals(44, result); - + vars.put("TVALOGAR", null); String jexlExp = "TVALOGAR==null?'SIMON':'SIMONAZO'"; script = jexl.createScript(jexlExp); result = script.execute(ctxt); Assert.assertEquals("SIMON", result); - + jexlExp = "TVALOGAR.PEPITO==null?'SIMON':'SIMONAZO'"; script = jexl.createScript(jexlExp); - + Map tva = new LinkedHashMap(); tva.put("PEPITO", null); vars.put("TVALOGAR", tva); result = script.execute(ctxt); Assert.assertEquals("SIMON", result); - + vars.remove("TVALOGAR"); ctxt.set("TVALOGAR.PEPITO", null); result = script.execute(ctxt); Assert.assertEquals("SIMON", result); } - + @Test public void test315() throws Exception { JexlEngine jexl = new JexlBuilder().strict(true).create(); @@ -323,4 +323,26 @@ public class Issues300Test { result = script.execute(ctxt, (Object) null); Assert.assertEquals(52, result); } + + public static class ClazzB { + public int methodB() { + return 42; + } + } + public static class ClazzA { + public ClazzB methodA() { + return new ClazzB(); + } + } + + @Test + public void test317Tentative() throws Exception { + JexlEngine jexl = new JexlBuilder().strict(true).create(); + JexlContext ctxt = new MapContext(); + JexlScript script; + Object result; + script = jexl.createScript("x.methodA().methodB()", "x"); + result = script.execute(ctxt, new ClazzA()); + Assert.assertEquals(42, result); + } }