Uploaded image for project: 'Mule'
  1. Mule
  2. MULE-5496

ScriptExpressionEvaluator does not throw Exception

    Details

    • User impact:
      Medium
    • Similar Issues:

      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?

        Attachments

          Activity

            People

            • Assignee:
              pablo.kraan Pablo Kraan
              Reporter:
              ruoat Ari Ruotsalainen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                25/Feb/12

                Zendesk Support