Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8230644

ConcurrentModificationException is not thrown.

    XMLWordPrintable

Details

    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


      Attachments

        Issue Links

          Activity

            People

              psonal Pallavi Sonal (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: