Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 3.1.1
-
Fix Version/s: 3.1.4 (EE only), 3.2.2 (EE only)
-
Component/s: Core: Expressions
-
Labels:None
-
User impact:Medium
-
Similar Issues:None
Description
Let's assume that I wanted to do some logic in groovy expression when inserting data to database. I have following jdbc-endpoint query configuration:
<jdbc:connector name="foo-connector" dataSource-ref="foo-ds"> <jdbc:query key="insertFoos" value=" INSERT INTO FOO (field1, field2) VALUES (#[groovy:payload.bar], #[groovy:throw new RuntimeException('field2 gets inserted with null instead of error in JdbcMessageDispatcher')])" /> </jdbc:connector>
For simpler example I omitted the actual logic by throwing an Exception intentionally.
When I call the endpoint, no Exception is thrown to Mule. Only null value is inserted in the database. I think it is very dangerous if an Exception is not thrown when evaluating an expression. Now corrupted data may be added to database.
I think the cause is in
AbstractScriptExpressionEvaluator.java
public Object evaluate(String expression, MuleMessage message) { Scriptable script = getScript(expression); script.setMuleContext(muleContext); Bindings bindings = script.getScriptEngine().createBindings(); script.populateBindings(bindings, message); try { return script.runScript(bindings); } catch (ScriptException e) { return null; } }
The ScriptException is omitted brutally. Could the exception be propagated so I would sleep better at nights? ![]()