You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/02/08 12:03:45 UTC

DO NOT REPLY [Bug 38565] New: - java.lang.ArrayIndexOutOfBoundsException

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565

           Summary: java.lang.ArrayIndexOutOfBoundsException
           Product: Commons
           Version: 3.1
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Collections
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: stijn.christiaens@vub.ac.be


In BoundedFifoBuffer (line 340):

                // Other elements require us to shift the subsequent elements

                int i = lastReturnedIndex + 1;

                while (i != end) {

                    if (i >= maxElements) {

                        elements[i - 1] = elements[0];

                        i = 0;

                    } else {

                        elements[i - 1] = elements[i];

                        i++;

                    }

                }
An AIOOBException is thrown at line 347 when trying to remove an element and i = 0.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38565] - [collections] java.lang.ArrayIndexOutOfBoundsException

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565


gudnabrsam@yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE




------- Additional Comments From gudnabrsam@yahoo.com  2006-02-08 17:05 -------
Looks like a duplicate of bug 33071.

*** This bug has been marked as a duplicate of 33071 ***

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38565] - [collections] java.lang.ArrayIndexOutOfBoundsException

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565





------- Additional Comments From stijn.christiaens@vub.ac.be  2006-02-08 16:41 -------
This little class recreates the bug. It must have something to do with the
automatic remove (which increases the member attribute start), because if there
is no overflow (and thus automatic remove) the problem does not occur. I hope
this helps.

import java.util.Collection;
import java.util.Iterator;

import org.apache.commons.collections.buffer.CircularFifoBuffer;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Collection<String> breadCrumbs = new CircularFifoBuffer(4);
		breadCrumbs.add("1");
		breadCrumbs.add("2");
		breadCrumbs.add("3");
		breadCrumbs.add("4");
		breadCrumbs.add("5");
		
		String current = "2";

		Iterator<String> iter = breadCrumbs.iterator();
		boolean remove = false;
		while (iter.hasNext()) {
			String temp = iter.next();
			if (remove) {
				iter.remove();
			}
			if (current.equals(temp)) {
				remove = true;
			}
		}
		if (!remove) {
			breadCrumbs.add(current);
		}
		
		iter = breadCrumbs.iterator();
		while (iter.hasNext()) {
			String temp = iter.next();
			System.out.println(temp);
		}		
	}

}


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38565] - [collections] java.lang.ArrayIndexOutOfBoundsException

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565


gudnabrsam@yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|java.lang.ArrayIndexOutOfBou|[collections]
                   |ndsException                |java.lang.ArrayIndexOutOfBou
                   |                            |ndsException




------- Additional Comments From gudnabrsam@yahoo.com  2006-02-08 15:21 -------
Looking at the code I don't immediately see how this is possible.  Can you
attach a testcase (simple main() harness or whatever) that reproduces the problem?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38565] - [collections] java.lang.ArrayIndexOutOfBoundsException

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565





------- Additional Comments From stijn.christiaens@vub.ac.be  2006-02-08 16:11 -------
Actually I am using a CircularFifoBuffer in my class, which extends the
...collections.buffer.BoundedFifoBuffer.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38565] - [collections] java.lang.ArrayIndexOutOfBoundsException

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565





------- Additional Comments From gudnabrsam@yahoo.com  2006-02-08 15:54 -------
Silly question: are you using org.apache.commons.collections.BoundedFifoBuffer
or org.apache.commons.collections.buffer.BoundedFifoBuffer?  Based on the code
you provided in the beginning, the former?  Maybe you should try the latter.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38565] - [collections] java.lang.ArrayIndexOutOfBoundsException

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565





------- Additional Comments From gudnabrsam@yahoo.com  2006-02-08 17:03 -------
I can recreate w/ 3.1 but not with SVN HEAD; therefore the bug has already been
fixed.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38565] - [collections] java.lang.ArrayIndexOutOfBoundsException

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565





------- Additional Comments From stijn.christiaens@vub.ac.be  2006-02-08 15:31 -------
This is the code that caused the bug. The variable breadCrumbs is a
BoundedFifoBuffer, but we use the Collection interface.
The target is to run over the buffer. If we encounter an element equal to the
one we have, all next elements in the buffer must be removed.
The Exception happens when the first element in the collection is the element we
have, so all the remaining ones must be removed, and only the first can stay.
The exception happens at the call of iter.remove()

		// see if this crumb is already present, because if it is
		// we must remove all later ones for a natural feel
		// breadCrumbs is a BoundedFifoBuffer, but we use the interface Collection
		boolean remove = false;
		Iterator<BreadCrumb> iter = breadCrumbs.iterator();
		while (iter.hasNext()) {
			BreadCrumb tempCrumb = iter.next();
			if (remove) {
				iter.remove();
			}
			if (crumb.equals(tempCrumb)) {
				remove = true;
			}
		}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38565] - [collections] java.lang.ArrayIndexOutOfBoundsException

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38565>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38565





------- Additional Comments From stijn.christiaens@vub.ac.be  2006-02-08 17:08 -------
Ok. Thanks for the swift assistance!

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org