You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Fabien KOCIK (JIRA)" <ji...@apache.org> on 2013/06/03 09:52:20 UTC

[jira] [Created] (CAMEL-6416) ScriptBuilder Some scripting are exception lost

Fabien KOCIK created CAMEL-6416:
-----------------------------------

             Summary: ScriptBuilder Some scripting are exception lost 
                 Key: CAMEL-6416
                 URL: https://issues.apache.org/jira/browse/CAMEL-6416
             Project: Camel
          Issue Type: Bug
          Components: camel-script
    Affects Versions: 2.10.4
            Reporter: Fabien KOCIK
            Priority: Minor


Hello, 

A little bug in *ScriptBuilder* class cause some script errors to be lost and replaced by a *NullPointerException* : 

{code:title=Encountered Exception}
Caused by: java.lang.NullPointerException
	at org.apache.camel.builder.script.ScriptBuilder.createScriptEvaluationException(ScriptBuilder.java:418)
	at org.apache.camel.builder.script.ScriptBuilder.evaluateScript(ScriptBuilder.java:348)
	at org.apache.camel.builder.script.ScriptBuilder.evaluate(ScriptBuilder.java:92)
	at org.apache.camel.builder.script.ScriptBuilder.evaluate(ScriptBuilder.java:96)
{code}

The problem occurs in *evaluateScript* method (line 336 to 352) :
{code:title=ScriptBuilder.evaluateScript}
    protected synchronized Object evaluateScript(Exchange exchange) {
        try {
            getScriptContext();
            populateBindings(getEngine(), exchange);
            addScriptEngineArguments(getEngine(), exchange);
            Object result = runScript(exchange);
            LOG.debug("The script evaluation result is: {}", result);
            return result;
        } catch (ScriptException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Script evaluation failed: " + e.getMessage(), e);
            }
            throw createScriptEvaluationException(e.getCause());
        } catch (IOException e) {
            throw createScriptEvaluationException(e);
        }
    }
{code}


We can see the following line (348) : 
{{throw createScriptEvaluationException(e.getCause());}}

In some cases, the exception cause is null and the error message become very unclear.

A simple workaround would be to write something like this :
{code:}
if (e.getCause() == null) {
    throw createScriptEvaluationException(e);
} else {
    throw createScriptEvaluationException(e.getCause());
}
{code}

I don't have some GIT software, so I could not provide a patch, sorry for that ;-)

Regards

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira