Mule
  1. Mule
  2. MULE-5496

ScriptExpressionEvaluator does not throw Exception

    Details

    • User impact:
      Medium
    • Similar Issues:
      MULE-2764Webapp example throws SAXParseException: Content is not allowed in prolog.
      MULE-6608MEL does not provide root exceptions
      MULE-5513CXF proxy does not propagate root cause of an exception.
      MULE-6631Throw Exceptions from Flow
      MULE-4610ObjectToJMSMessage throws Exception when payload is List of Maps
      MULE-2990Mule File Connector does not throw an exception while polling a directory if the directory is unreadable.
      MULE-5559HttpsConnector fails to throw exception on missing key store
      MULE-246Mule does not return Exceptions through Soap endpoints
      MULE-4630Configured Service Exception strategy does not get called for MessageRedeliveredException
      MULE-6624Allow MEL to throw any exception

      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?

        Activity

        Ari Ruotsalainen created issue -
        Mike Schilling made changes -
        Field Original Value New Value
        Priority To be reviewed [ 6 ] Critical [ 2 ]
        Pablo Kraan made changes -
        Assignee Pablo Kraan [ pablo.kraan ]
        Show
        Pablo Kraan added a comment - Fix 3.1.x http://fisheye.codehaus.org/changelog/mule/?cs=23659 Fix 3.2.x http://fisheye.codehaus.org/changelog/mule/?cs=23669 Fix 3.x http://fisheye.codehaus.org/changelog/mule/?cs=23670
        Pablo Kraan made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 3.1.4 [ 11079 ]
        Fix Version/s 3.2.2 [ 11105 ]
        Resolution Fixed [ 1 ]
        Ramiro Rinaudo made changes -
        Workflow Fixed Main Mule Workflow (after JIRA upgrade) [ 81242 ] Main Mule Workflow v1.0 [ 140094 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        302d 12h 34m 1 Pablo Kraan 20/Jan/12 02:21 PM

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development