Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-5808

[classlib][luni] add() method of listIterator implementation in AbstractList may throw unexpected ConcurrentModificationException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.0M6
    • 5.0M6
    • Classlib
    • None
    • Patch Available

    Description

      add() method of listIterator implementation in AbstractList may throw unexpected ConcurrentModificationException.
      Its behavior is different from the one of RI.

      Here is the test case:

      public class AbstractListTest extends junit.framework.TestCase {

      public void test_listIterator()

      { list = new MockArrayList(); ListIterator it = list.listIterator(); it.add("one"); it.add("two"); assertEquals(2,list.size()); }

      class MockArrayList<E> extends AbstractList<E> {

      ArrayList<E> list = new ArrayList<E>();

      public E remove(int idx)

      { modCount++; return list.remove(idx); }

      @Override
      public E get(int index)

      { return list.get(index); }

      @Override
      public int size()

      { return list.size(); }

      @Override
      public void add(int idx, E o)

      { modCount += 10; list.add(idx, o); }

      }

      }

      Test results:
      RI can pass this test.
      Harmony will throw a ConcurrentModificationException.

      Attachments

        1. Harmony-5808.diff
          1 kB
          Sean Qiu

        Activity

          People

            qiuxiaox Sean Qiu
            qiuxiaox Sean Qiu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: