[jboss-jira] [JBoss JIRA] Updated: (JBRULES-1173) java.lang.ArrayIndexOutOfBoundsException: 2 in file named "TupleIndexHashTable.java" in toArray() Method. I have fix and works fine.

Nageshwar Kunichetty (JIRA) jira-events at lists.jboss.org
Wed Sep 5 22:00:35 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBRULES-1173?page=all ]

Nageshwar Kunichetty updated JBRULES-1173:
------------------------------------------

    Workaround Description: 
So I had the following change in file "TupleIndexHashTable.java" and it was working  :

public Entry[] toArray() {
       Entry[] result = new Entry[this.factSize];
            int index = 0;
        System.out.println("this.table.length=" + this.table.length); 
        for ( int i = 0; i < this.table.length; i++ ) {
        	FieldIndexEntry fieldIndexEntry = (FieldIndexEntry)this.table[i];
            while ( fieldIndexEntry != null ) {
                Entry entry = fieldIndexEntry.getFirst();
                //while ( entry != null){
               while ( entry != null && index<result.length) {
                    result[index++] = entry;
                    entry = entry.getNext();
                }       
                fieldIndexEntry  = ( FieldIndexEntry ) fieldIndexEntry.getNext();
            }
        }
        return result;
    }

That is, in  innner while loop I added extra codition ("index<result.length") of  "while ( entry != null && index<result.length) {".
Fix  worked for me. I am not sure if this is already fixed. 
Some I was wondering if it is fixed could I know the fixed release version/patch?

Thanks.






  was:
So I had the following change in file "TupleIndexHashTable.java" and it was working  :

public Entry[] toArray() {
       // Entry[] result = new Entry[this.factSize];
    	 Entry[] result = new Entry[this.size];
        int index = 0;
        System.out.println("this.table.length=" + this.table.length); 
        for ( int i = 0; i < this.table.length; i++ ) {
        	FieldIndexEntry fieldIndexEntry = (FieldIndexEntry)this.table[i];
            while ( fieldIndexEntry != null ) {
                Entry entry = fieldIndexEntry.getFirst();
                //while ( entry != null){
               while ( entry != null && index<result.length) {
                    result[index++] = entry;
                    entry = entry.getNext();
                }       
                fieldIndexEntry  = ( FieldIndexEntry ) fieldIndexEntry.getNext();
            }
        }
        return result;
    }

That is, in  innner while loop I added extra codition ("index<result.length") of  "while ( entry != null && index<result.length) {".
Fix  worked for me. I am not sure if this is already fixed. 
Some I was wondering if it is fixed could I know the fixed release version/patch?

Thanks.







It was wrong piece of code pasted I have corrected it. Only fix I did was following :

That is, in innner while loop I added extra codition ("index<result.length") of "while ( entry != null && index<result.length) {". 
Fix worked for me. I am not sure if this is already fixed. 
Some I was wondering if it is fixed could I know the fixed release version/patch? 

I will send the test case tomorrow.

> java.lang.ArrayIndexOutOfBoundsException: 2 in file named "TupleIndexHashTable.java" in toArray() Method. I have fix and works fine.
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JBRULES-1173
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-1173
>             Project: JBoss Rules
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Reteoo
>    Affects Versions:  4.0.0.MR3
>         Environment: windows XP
>            Reporter: Nageshwar Kunichetty
>         Assigned To: Mark Proctor
>             Fix For: 4.0.2
>
>
> Sometimes while asserting specific facts I get the following exception in drools-core-4.0.0 :
> > java.lang.ArrayIndexOutOfBoundsException: 26
> >         at org.drools.util.TupleIndexHashTable.toArray(TupleIndexHashTable.java:178)
> >         at org.drools.reteoo.CollectNode.assertObject(CollectNode.java:212)
> >         at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:317)
> >         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)

-- 
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