JDK-8230644 : ConcurrentModificationException is not thrown.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 8u221
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2019-09-02
  • Updated: 2021-01-27
  • Resolved: 2019-09-05
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 7/ JRE 1.8.0_221

A DESCRIPTION OF THE PROBLEM :
Create an Arraylist of Integer. And add some integer to it. And then while iterate over list, remove last second element from list. It will not throw exception.
Sample :
List<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
for(Integer i: list) {
if(i.equals(3) {
list.remove(i);
}
}


REGRESSION : Last worked in version 8u221

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create an ArrayList
2) Add some element to arraylist using the add method
3) Iterate over arraylist
4) Try to remove the last second element using if condition and using remove method of arraylist.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
While calling list.remove(i) method to remove 3 from the list, ConcurrentModificationException should be thrown.
ACTUAL -
It is not throwing ConcurrentModificationException

---------- BEGIN SOURCE ----------
List<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
for(Integer i: list) {
if(i.equals(3) {
list.remove(i);
}
}
---------- END SOURCE ----------

FREQUENCY : always