You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ra...@apache.org on 2009/08/08 04:03:00 UTC
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
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 <hbiestro at gmail dot com>.
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 {