Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

NullPointerException if parenthesis are missing in when statements #107

Open
pgambier opened this issue Apr 27, 2017 · 1 comment
Open

Comments

@pgambier
Copy link

In a when statement, if the user forget the enclosing parameters of the condition, a NullPointerException is thrown:

java.lang.NullPointerException: Cannot invoke method or2() on null object
        at paradesMarseille_27_02_2017$_run_closure12.doCall(paradesMarseille_27.02.2017.groovy:165)
        at paradesMarseille_27_02_2017$_run_closure12.doCall(paradesMarseille_27.02.2017.groovy)
        at com.rte_france.itesla.action.dsl.ActionDslLoader$_load_closure2.doCall(ActionDslLoader.groovy:144)
        at paradesMarseille_27_02_2017.run(paradesMarseille_27.02.2017.groovy:157)
        at com.rte_france.itesla.action.dsl.ActionDslLoader.load(ActionDslLoader.groovy:191)
        at com.rte_france.itesla.action.simulator.tool.ActionSimulatorTool.run(ActionSimulatorTool.java:164)
        at eu.itesla_project.commons.tools.CommandLineTools.run(CommandLineTools.java:125)
        at eu.itesla_project.commons.tools.Main.main(Main.java:18)

Here is a groovy example to reproduce this bug:

rule('my_rule') {
    when my_cond1 || my_cond2
    apply 'my_action'
}

The when statement is translated to:

when(my_cond).or2(my_cond2)

The NullPointerException is throws because the return value of the when method is null. A workaround is to add parenthesis to the when statement:

rule('my_rule') {
    when (my_cond1 || my_cond2)
    apply 'my_action'
}
@pgambier
Copy link
Author

This bug cannot be reproduced in the latest versions. Were there changes in the code which fixed this bug "by chance" ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants