-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8u77
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) Client VM (build 25.77-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
windows 7. This issue is exist in all the environments.
A DESCRIPTION OF THE PROBLEM :
Able to delete a element from list usring list remove() while iteration the same list.
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
List<String> list = new ArrayList<String>();
list.add("Thiru");
list.add("Thiru1");
list.add("Thiru2");
for(String str : list){
if("Thiru1".equals(str)){
list.remove(str);
}
}
System.out.println("Size After:"+list.size());
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
List<String> list = new ArrayList<String>();
list.add("Thiru");
list.add("Thiru1");
list.add("Thiru2");
for(String str : list){
if("Thiru1".equals(str)){
list.remove(str);
}
}
System.out.println("Size After:"+list.size());
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
we should get ConcurrentModificationExceptoin.
ACTUAL -
element should not get deleted from list & it should throw ConcurrentModificationExceptoin
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.thiru;
import java.util.ArrayList;
import java.util.List;
public class JavaBug {
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
List<String> list = new ArrayList<String>();
list.add("Thiru");
list.add("Thiru1");
list.add("Thiru2");
for(String str : list){
if("Thiru1".equals(str)){
list.remove(str);
}
}
System.out.println("Size After:"+list.size());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No work around.
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) Client VM (build 25.77-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
windows 7. This issue is exist in all the environments.
A DESCRIPTION OF THE PROBLEM :
Able to delete a element from list usring list remove() while iteration the same list.
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
List<String> list = new ArrayList<String>();
list.add("Thiru");
list.add("Thiru1");
list.add("Thiru2");
for(String str : list){
if("Thiru1".equals(str)){
list.remove(str);
}
}
System.out.println("Size After:"+list.size());
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
List<String> list = new ArrayList<String>();
list.add("Thiru");
list.add("Thiru1");
list.add("Thiru2");
for(String str : list){
if("Thiru1".equals(str)){
list.remove(str);
}
}
System.out.println("Size After:"+list.size());
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
we should get ConcurrentModificationExceptoin.
ACTUAL -
element should not get deleted from list & it should throw ConcurrentModificationExceptoin
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.thiru;
import java.util.ArrayList;
import java.util.List;
public class JavaBug {
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
List<String> list = new ArrayList<String>();
list.add("Thiru");
list.add("Thiru1");
list.add("Thiru2");
for(String str : list){
if("Thiru1".equals(str)){
list.remove(str);
}
}
System.out.println("Size After:"+list.size());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No work around.
- duplicates
-
JDK-8136821 ConcurrentModificationException not thrown when removing the next to last element , less than expected number of iterations
-
- Closed
-