[jboss-jira] [JBoss JIRA] Created: (JBRULES-1006) NullPointerException when using "from collect"
Brian Stiles (JIRA)
jira-events at lists.jboss.org
Fri Jul 13 18:36:03 EDT 2007
NullPointerException when using "from collect"
----------------------------------------------
Key: JBRULES-1006
URL: http://jira.jboss.com/jira/browse/JBRULES-1006
Project: JBoss Rules
Issue Type: Bug
Security Level: Public (Everyone can see)
Reporter: Brian Stiles
Assigned To: Mark Proctor
It seems that using more than one rule with "from collect"--or possibly "from collect ( Foo() from someCall() )--causes Declaration.getPattern().getOffset() to be incorrect, resulting in a NullPointerException in ReteTuple.get(int). This should be more clear after running the included code.
The following test case demonstrates the problem.
--
package sample;
import java.io.StringReader;
import java.util.HashSet;
import java.util.Set;
import org.drools.RuleBase;
import org.drools.RuleBaseConfiguration;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
public class FromProblem {
public static void main(String[] args) throws Exception {
final PackageBuilderConfiguration packageBuilderConfiguration =
new PackageBuilderConfiguration();
final PackageBuilder packageBuilder = new PackageBuilder(packageBuilderConfiguration);
packageBuilder.addPackageFromDrl(new StringReader("\n"
+ "package sample\n"
+ "\n"
+ "import java.util.ArrayList;"
+ "import sample.FromProblem;"
+ "global sample.FromProblem x;"
+ "\n"
+ "rule MyRule\n"
+ " dialect \"java\"\n"
+ "\n"
+ " when\n"
+ " $i : ArrayList() from collect(Integer() from x.getIntegers())\n"
+ " $k : ArrayList() from collect(Integer() from x.getIntegers())\n"
+ " then \n"
+ " System.out.println($i);\n"
+ " System.out.println($k);\n"
+ "end \n"));
final RuleBaseConfiguration ruleBaseConfiguration = new RuleBaseConfiguration();
final RuleBase ruleBase = RuleBaseFactory.newRuleBase(ruleBaseConfiguration);
ruleBase.addPackage(packageBuilder.getPackage());
final StatefulSession session = ruleBase.newStatefulSession();
session.setGlobal("x", new FromProblem());
session.fireAllRules();
}
public Set<Integer> getIntegers() {
final HashSet<Integer> set = new HashSet<Integer>();
set.add(1);
return set;
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list