[
http://jira.jboss.com/jira/browse/JBRULES-854?page=comments#action_12363199 ]
Alexandre Gattiker commented on JBRULES-854:
--------------------------------------------
Same bug found with simpler case and no PropertyChangeSupport:
package com.sample
import com.sample.Parent;
import com.sample.Child;
rule "rule2"
salience 1
when
Child(name=="usage", value == "1")
Child(name=="usage", value == "6")
then
System.out.println("Allow");
end
rule "rule3"
salience 1
when
Child(name=="usage", value == "1")
Child(name=="usage", value == "7")
then
System.out.println("Deny");
end
Parent parent = new Parent();
parent.setTypeName("10");
workingMemory.assertObject( parent );
Child child = new Child();
child.setName("usage");
workingMemory.assertObject( child );
workingMemory.fireAllRules();
java.lang.NullPointerException
at
org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.setValue(CompositeObjectSinkAdapter.java:478)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:292)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:147)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:20)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:183)
at org.drools.reteoo.Rete.assertObject(Rete.java:121)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:201)
at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(ReteooWorkingMemory.java:70)
at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:724)
at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:548)
at com.sample.DroolsTest.main(DroolsTest.java:31)
I have following problem with null valuated string properties
-------------------------------------------------------------
Key: JBRULES-854
URL:
http://jira.jboss.com/jira/browse/JBRULES-854
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Reteoo
Affects Versions: 4.0.0.MR2
Environment: Windows XP SP2
Reporter: Vesa Tuononen
Assigned To: Mark Proctor
Priority: Blocker
I have very simple object with PropertyChangeSupport.
Java code listed bellow object and test method:
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.InputStreamReader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
public class OwnTest{
public static class Row{
private final PropertyChangeSupport changes = new PropertyChangeSupport( this );
private String field1;
private String field2;
public Row(){}
public String getField1() {
return field1;
}
public void setField1(String field1) {
String oldField1 = this.field1;
this.field1 = field1;
this.changes.firePropertyChange( "field1",
oldField1,
this.field1 );
}
public String getField2() {
return field2;
}
public void setField2(String field2) {
String oldField2 = this.field2;
this.field2 = field2;
this.changes.firePropertyChange( "field2",
oldField2,
this.field2 );
}
public void addPropertyChangeListener(final PropertyChangeListener l) {
this.changes.addPropertyChangeListener( l );
}
public void removePropertyChangeListener(final PropertyChangeListener l) {
this.changes.removePropertyChangeListener( l );
}
}
/**
* @param args
* @throws Exception
* @throws DroolsParserException
* @throws Exception
*/
public static void main(String[] args) throws Exception {
Row r = new Row();
r.setField1(null);
r.setField2(null);
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromXml(new InputStreamReader(
OwnTest.class.getResourceAsStream("rule.xml")));
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( builder.getPackage() );
StatefulSession workingMemory = ruleBase.newStatefulSession();
workingMemory.assertObject(r, true);
workingMemory.fireAllRules();
}
}
and rule.xml
<?xml version="1.0" encoding="UTF-8"?>
<package name="test"
xmlns="http://drools.org/drools-3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-3.0 drools-3.0.xsd">
<import name="OwnTest.Row"/>
<rule name="1">
<lhs>
<pattern object-type="Row">
<field-constraint field-name="field1">
<literal-restriction evaluator="==" value="1" />
</field-constraint>
</pattern>
</lhs>
<rhs>
System.out.println("--"+input.getField1());
input.setField1("2");
</rhs>
</rule>
<rule name="2">
<lhs>
<pattern identifier="input" object-type="Row">
<field-constraint field-name="field1">
<literal-restriction evaluator="==" value="2" />
</field-constraint>
</pattern>
</lhs>
<rhs>
System.out.println("--"+input.getField1());
input.setField1("3");
</rhs>
</rule>
<rule name="3">
<lhs>
<pattern identifier="input" object-type="Row">
<field-constraint field-name="field1">
<literal-restriction evaluator="==" value="3" />
</field-constraint>
</pattern>
</lhs>
<rhs>
System.out.println("--"+input.getField1());
input.setField1("4");
</rhs>
</rule>
<rule name="4">
<lhs>
<pattern identifier="input" object-type="Row">
<field-constraint field-name="field1">
<literal-restriction evaluator="==" value="4" />
</field-constraint>
</pattern>
</lhs>
<rhs>
System.out.println("--"+input.getField1());
input.setField1("0");
input.setField2("5");
</rhs>
</rule>
<rule name="5">
<lhs>
<pattern identifier="input" object-type="Row">
<field-constraint field-name="field2">
<literal-restriction evaluator="==" value="2" />
</field-constraint>
</pattern>
</lhs>
<rhs>
System.out.println("--"+input.getField1());
System.out.println("--"+input.getField2());
input.setField2("2b");
</rhs>
</rule>
</package>
with this rule set I get following StackTrace:
Exception in thread "main" java.lang.NullPointerException
at
org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.setValue(CompositeObjectSinkAdapter.java:478)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:292)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:183)
at org.drools.reteoo.Rete.assertObject(Rete.java:121)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:201)
at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(ReteooWorkingMemory.java:70)
at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:724)
at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:568)
but if I remove some rules everything works fine.
--
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