NullPointerException if parenthesis are missing in when statements
pgambier opened this issue · 1 comments
pgambier commented
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 commented
This bug cannot be reproduced in the latest versions. Were there changes in the code which fixed this bug "by chance" ?