Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 63971 invoked from network); 8 Aug 2009 02:03:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Aug 2009 02:03:17 -0000 Received: (qmail 91460 invoked by uid 500); 8 Aug 2009 02:03:23 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 91365 invoked by uid 500); 8 Aug 2009 02:03:23 -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 91356 invoked by uid 99); 8 Aug 2009 02:03:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Aug 2009 02:03:23 +0000 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; Sat, 08 Aug 2009 02:03:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2349E2388985; Sat, 8 Aug 2009 02:03:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r802284 - in /commons/proper/jexl/branches/2.0/src: main/java/org/apache/commons/jexl/Interpreter.java test/java/org/apache/commons/jexl/AssignTest.java Date: Sat, 08 Aug 2009 02:03:00 -0000 To: commits@commons.apache.org From: rahul@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090808020301.2349E2388985@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rahul Date: Sat Aug 8 02:03:00 2009 New Revision: 802284 URL: http://svn.apache.org/viewvc?rev=802284&view=rev Log: Lenient mode should not throw exception when getting/setting an undefined property. Patch by Henri Biestro . JEXL-80 Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/AssignTest.java Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java?rev=802284&r1=802283&r2=802284&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java (original) +++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java Sat Aug 8 02:03:00 2009 @@ -1207,7 +1207,13 @@ if (node == null) { throw new RuntimeException(xany); } else { - throw new JexlException(node, "get object property error", xany); + JexlException xjexl = new JexlException(node, "get object property error", xany); + if (strict) { + throw xjexl; + } + if (!silent) { + logger.warn(xjexl.getMessage()); + } } } } @@ -1248,6 +1254,7 @@ } } } + JexlException xjexl = null; JexlPropertySet vs = uberspect.getPropertySet(object, attribute, value, node); if (vs != null) { try { @@ -1256,31 +1263,41 @@ if (node != null && cache) { node.jjtSetValue(vs); } + return; } catch (RuntimeException xrt) { - throw node == null ? xrt : new JexlException(node, "set object property error", xrt); + if (node == null) { + throw xrt; + } + xjexl = new JexlException(node, "set object property error", xrt); } catch (Exception xany) { if (node == null) { throw new RuntimeException(xany); - } else { - throw new JexlException(node, "set object property error", xany); } + xjexl = new JexlException(node, "set object property error", xany); } - return; } - String error = "unable to set object property" - + ", class: " + object.getClass().getName() - + ", property: " + attribute; - if (node == null) { - throw new UnsupportedOperationException(error); + if (xjexl == null) { + String error = "unable to set object property" + + ", class: " + object.getClass().getName() + + ", property: " + attribute; + if (node == null) { + throw new UnsupportedOperationException(error); + } + xjexl = new JexlException(node, error, null); + } + if (strict) { + throw xjexl; + } + if (!silent) { + logger.warn(xjexl.getMessage()); } - throw new JexlException(node, error, null); } /** * Unused, satisfy ParserVisitor interface. * @param node a node - * @param data the date - * @return does not return, + * @param data the data + * @return does not return */ public Object visit(SimpleNode node, Object data) { throw new UnsupportedOperationException("Not supported yet."); Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/AssignTest.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/AssignTest.java?rev=802284&r1=802283&r2=802284&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/AssignTest.java (original) +++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/AssignTest.java Sat Aug 8 02:03:00 2009 @@ -26,6 +26,7 @@ private static final JexlEngine ENGINE = new JexlEngine(); static { ENGINE.setSilent(false); + ENGINE.setLenient(false); } public static class Froboz {