[jboss-jira] [JBoss JIRA] Created: (JBRULES-2528) NullPointerException during rule compilation on ReturnValueRestriction.replaceDeclaration instead of clear, understandable compiler error
Geoffrey De Smet (JIRA)
jira-events at lists.jboss.org
Sun May 30 09:29:08 EDT 2010
NullPointerException during rule compilation on ReturnValueRestriction.replaceDeclaration instead of clear, understandable compiler error
-----------------------------------------------------------------------------------------------------------------------------------------
Key: JBRULES-2528
URL: https://jira.jboss.org/browse/JBRULES-2528
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-compiler (expert)
Affects Versions: 5.1.0.M2
Reporter: Geoffrey De Smet
Assignee: Edson Tirelli
Priority: Minor
Fix For: FUTURE
With this rule:
rule "unwantedPatternFreeBeforeWorkSequencePattern"
when
$pattern : FreeBeforeWorkSequencePattern(
$firstWorkDayOfWeek : firstWorkDayOfWeek,
$workShiftType : workShiftType,
$workDayLength : workDayLength
)
PatternContractLine(
pattern == $pattern, $contract : contract
)
Assignment(
eval($firstWorkDayOfWeek == null) || (shiftDateDayOfWeek == $firstWorkDayOfWeek),
eval($workShiftType == null) || (shiftType == $workShiftType),
contract == $contract,
$employee : employee, $firstWorkDayIndex : shiftDateDayIndex
)
eval($workDayLength < 2) or Assignment(
eval($workShiftType == null) || (shiftType == $workShiftType),
employee == $employee,
shiftDateDayIndex == ($firstWorkDayIndex + 1)
)
// A free day before
EmployeeFreeSequence(
employee == $employee,
lastDayIndex == ($firstWorkDayIndex - 1)
)
then
insertLogical(new IntConstraintOccurrence("unwantedPatternFreeBeforeWorkSequencePattern",
ConstraintType.NEGATIVE_SOFT,
$pattern.getWeight(),
$employee, $pattern, $firstWorkDayIndex));
end
I get a NullPointerException.
The problem seems to lie in:
eval($workDayLength < 2) or Assignment(...)
EmployeeFreeSequence(
...
lastDayIndex == ($firstWorkDayIndex - 1)
)
So I should not use "or" in this way, but it would be nice to get a readable, understandable error message.
Exception in thread "main" java.lang.NullPointerException
at org.drools.rule.ReturnValueRestriction.replaceDeclaration(ReturnValueRestriction.java:193)
at org.drools.rule.ReturnValueConstraint.replaceDeclaration(ReturnValueConstraint.java:78)
at org.drools.rule.LogicTransformer.processElement(LogicTransformer.java:162)
at org.drools.rule.LogicTransformer.processElement(LogicTransformer.java:189)
at org.drools.rule.LogicTransformer.fixClonedDeclarations(LogicTransformer.java:130)
at org.drools.rule.LogicTransformer.transform(LogicTransformer.java:112)
at org.drools.rule.Rule.getTransformedLhs(Rule.java:536)
at org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:100)
at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:117)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:409)
at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:638)
at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:520)
at org.drools.reteoo.ReteooRuleBase.addPackage(ReteooRuleBase.java:435)
at org.drools.planner.config.localsearch.LocalSearchSolverConfig.buildRuleBase(LocalSearchSolverConfig.java:208)
at org.drools.planner.config.localsearch.LocalSearchSolverConfig.buildSolver(LocalSearchSolverConfig.java:170)
at org.drools.planner.benchmark.SolverBenchmarkSuite.benchmark(SolverBenchmarkSuite.java:183)
at org.drools.planner.benchmark.XmlSolverBenchmarker.benchmark(XmlSolverBenchmarker.java:72)
at org.drools.planner.examples.common.app.CommonBenchmarkApp.process(CommonBenchmarkApp.java:25)
at org.drools.planner.examples.nurserostering.app.NurseRosteringBenchmarkApp.main(NurseRosteringBenchmarkApp.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list