JDK-7145112 : Error in method Iterator.remove() from ArrayBlockingQueue
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 6u30
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-02-13
  • Updated: 2014-07-03
  • Resolved: 2012-04-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6u31-rev b25Fixed
Related Reports
Relates :  
Relates :  
Description
During backporting test fixes was found product issue which was hidden by test error.
Method remove() from ArrayBlockingQueue's iterator work incorrectly
if delete no first element. For example:

import java.util.Iterator;
import java.util.concurrent.ArrayBlockingQueue;

public class ABQueue {

    public static void main(String[] args) throws Exception {
        ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(3);
        queue.add(1);
        queue.add(2);
        queue.add(3);
        System.out.println("Size before: "+queue.size());
        Iterator<Integer> i = queue.iterator();
        i.next();
        i.next();
        i.remove();
        i.next();
        i.remove();
        System.out.println("Size after: "+queue.size());
    }
}

Results for 1.6.0_29b11:
java.exe ABQueue
Size before: 3
Size after: 1

Results for 1.6.0_30b12:
java.exe ABQueue
Size before: 3
Size after: 2

Comments
EVALUATION The issue was introduced by porting a fix for 7014263 into 6u30 from Revision 1.60 of ArrayBlockingQueue.java from Doug Lea's JSR-166 CVS. This problem does exist in Rev 1.60 as well and was fixed in later revisions in JSR-166 CVS. It does not exist in jdk7 as it includes a bundle update from that repo. The fix would be to port changes in remove method from revisions 1.61 and 1.71.
14-02-2012