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

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

     [ https://issues.apache.org/jira/browse/CAMEL-6416?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang updated CAMEL-6416:
--------------------------------

    Fix Version/s:     (was: 2.10.5)
                   2.10.6
    
> 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
>            Assignee: Willem Jiang
>            Priority: Minor
>             Fix For: 2.10.6, 2.11.1, 2.12.0
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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