-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b08
-
generic
-
generic
-
Verified
SYNOPSIS
--------
NegativeArraySizeException reported in ArrayBlockingQueue under load
OPERATING SYSTEM
----------------
All
FULL JDK VERSION
----------------
All Java 6 releases and all JDK7 builds
Does not occur with 5.0
DESCRIPTION from LICENSEE
-------------------------
Instances of ArrayBlockingQueue (and possibly other collection classes in the java.util.concurrent package) can become broken under load, resulting in NegativeArraySizeExceptions.
STEPS TO REPRODUCE
------------------
1. Run the supplied testcase repeatedly:
java CutDownArrayBlockingQueueTest
The problem is intermittent. When running the test repeatedly in quick succession, I see the exceptions about once every 5-10 executions - sometimes more, sometimes less.
OBSERVED RESULT
---------------
One or more exceptions similar to the following:
Exception in thread "Thread-27" java.lang.NegativeArraySizeException
at java.util.concurrent.ArrayBlockingQueue.toArray(ArrayBlockingQueue.java:483)
at WorkerThread.run(CutDownArrayBlockingQueueTest.java:142)
Exception in thread "Thread-72" java.lang.NegativeArraySizeException
at java.util.concurrent.ArrayBlockingQueue.toArray(ArrayBlockingQueue.java:483)
at WorkerThread.run(CutDownArrayBlockingQueueTest.java:156)
Exception in thread "Thread-80" java.lang.NegativeArraySizeException
at java.util.concurrent.ArrayBlockingQueue.toArray(ArrayBlockingQueue.java:483)
at WorkerThread.run(CutDownArrayBlockingQueueTest.java:156)
Exception in thread "Thread-47" java.lang.NegativeArraySizeException
at java.util.concurrent.ArrayBlockingQueue.toArray(ArrayBlockingQueue.java:483)
at WorkerThread.run(CutDownArrayBlockingQueueTest.java:156)
EXPECTED RESULT
---------------
This situation should never arise. It seems that one or more elements can be removed from the ArrayBlocking queue even when there are no elements to be removed, which clearly should not occur. We should receive a NoSuchElementException when invoking remove() on an empty queue.
For example, in a single threaded context the following code:
ArrayBlockingQueue queue = new ArrayBlockingQueue(20);
queue.remove();
will *always* result in this exception:
Exception in thread "main" java.util.NoSuchElementException
at java.util.AbstractQueue.remove(AbstractQueue.java:97)
It seems that this does not always happen in the multithreaded stress test we have provided.
--------
NegativeArraySizeException reported in ArrayBlockingQueue under load
OPERATING SYSTEM
----------------
All
FULL JDK VERSION
----------------
All Java 6 releases and all JDK7 builds
Does not occur with 5.0
DESCRIPTION from LICENSEE
-------------------------
Instances of ArrayBlockingQueue (and possibly other collection classes in the java.util.concurrent package) can become broken under load, resulting in NegativeArraySizeExceptions.
STEPS TO REPRODUCE
------------------
1. Run the supplied testcase repeatedly:
java CutDownArrayBlockingQueueTest
The problem is intermittent. When running the test repeatedly in quick succession, I see the exceptions about once every 5-10 executions - sometimes more, sometimes less.
OBSERVED RESULT
---------------
One or more exceptions similar to the following:
Exception in thread "Thread-27" java.lang.NegativeArraySizeException
at java.util.concurrent.ArrayBlockingQueue.toArray(ArrayBlockingQueue.java:483)
at WorkerThread.run(CutDownArrayBlockingQueueTest.java:142)
Exception in thread "Thread-72" java.lang.NegativeArraySizeException
at java.util.concurrent.ArrayBlockingQueue.toArray(ArrayBlockingQueue.java:483)
at WorkerThread.run(CutDownArrayBlockingQueueTest.java:156)
Exception in thread "Thread-80" java.lang.NegativeArraySizeException
at java.util.concurrent.ArrayBlockingQueue.toArray(ArrayBlockingQueue.java:483)
at WorkerThread.run(CutDownArrayBlockingQueueTest.java:156)
Exception in thread "Thread-47" java.lang.NegativeArraySizeException
at java.util.concurrent.ArrayBlockingQueue.toArray(ArrayBlockingQueue.java:483)
at WorkerThread.run(CutDownArrayBlockingQueueTest.java:156)
EXPECTED RESULT
---------------
This situation should never arise. It seems that one or more elements can be removed from the ArrayBlocking queue even when there are no elements to be removed, which clearly should not occur. We should receive a NoSuchElementException when invoking remove() on an empty queue.
For example, in a single threaded context the following code:
ArrayBlockingQueue queue = new ArrayBlockingQueue(20);
queue.remove();
will *always* result in this exception:
Exception in thread "main" java.util.NoSuchElementException
at java.util.AbstractQueue.remove(AbstractQueue.java:97)
It seems that this does not always happen in the multithreaded stress test we have provided.
- relates to
-
JDK-7145112 Error in method Iterator.remove() from ArrayBlockingQueue
- Resolved
-
JDK-7005424 Resync java.util.concurrent classes with Dougs CVS - Jan 2011
- Closed