[
http://jira.jboss.com/jira/browse/JBRULES-722?page=comments#action_12356701 ]
Pierre Paysant-Le Roux commented on JBRULES-722:
------------------------------------------------
After investigating, I found that this exception occured when building a new
DefaultBetaConstaint object. The first constaint is inserted in the LinkedList with the
insertAfter method. And because it's the first constaint, the list is empty.
Here is a simple rule that is problematic :
rule "problem"
when
Object1($a :a, $b : b, $c : c, $d : d, $e : e)
not Object2(a == $a, #1st constraint
b == $b, #2nd constaint
c == $c, #3rd constaint
d == $d, #4th constaint
e == $e) #5th constaint
then
System.out.println( "no problem" );
end
The DefaultBetaConstraints is used for a beta node with more than four constaints.
I thing there is also a problem with Rete viewer that says : java.lang.Exception : Unable
to parse rules to show RETE view. I have no idea how to debug the Eclipse IDE, so I have
no more details. The bugfix I purposed does'nt solve the RETE viewer problem, but I
think it solve the DefaultBetaConstaint's constructor problem.
NullPointerException when using inserAfter method with an empty
LinkedList
--------------------------------------------------------------------------
Key: JBRULES-722
URL:
http://jira.jboss.com/jira/browse/JBRULES-722
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 3.1-m1
Environment: Windows, jdk 1.5
Reporter: Pierre Paysant-Le Roux
Assigned To: Edson Tirelli
JBoss rules throws a NullPointerException when adding my rules file. The problem is with
the inserAfter methode in LinkedList. Debug shows that it appends when inserting a node in
an empty list.
I wrote a simple test case to illustrate the problem :
Index: drools-core/src/test/java/org/drools/util/LinkedListTest.java
===================================================================
--- drools-core/src/test/java/org/drools/util/LinkedListTest.java (revision 9968)
+++ drools-core/src/test/java/org/drools/util/LinkedListTest.java (working copy)
@@ -264,4 +264,7 @@
3 );
}
-}
\ No newline at end of file
+ public void testInsertAfter(){
+ this.list.insertAfter( null, this.node1 );
+ }
+}
And a patch to avoid the problem :
Index: drools-core/src/main/java/org/drools/util/LinkedList.java
===================================================================
--- drools-core/src/main/java/org/drools/util/LinkedList.java (revision 9968)
+++ drools-core/src/main/java/org/drools/util/LinkedList.java (working copy)
@@ -151,17 +151,21 @@
}
if ( existingNode == null ) {
- // if existing node is null, then insert it as a first node
- final LinkedListNode node = this.firstNode;
- node.setPrevious( newNode );
- newNode.setNext( node );
- this.firstNode = newNode;
+ if(this.isEmpty())
+ this.add(newNode);
+ else{
+ // if existing node is null, then insert it as a first node
+ final LinkedListNode node = this.firstNode;
+ node.setPrevious( newNode );
+ newNode.setNext( node );
+ this.firstNode = newNode;
+ }
} else if ( existingNode == this.lastNode ) {
existingNode.setNext(newNode);
newNode.setPrevious( existingNode );
this.lastNode = newNode;
} else {
- ((LinkedListNode)existingNode.getNext()).setPrevious( newNode );
+ ((LinkedListNode)existingNode.getNext()).setPrevious( newNode );
newNode.setNext( existingNode.getNext() );
existingNode.setNext( newNode );
newNode.setPrevious( existingNode );
Excuse me if I'm wrong.
--
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