Cannot remove elements from CopyOnWriteArrayList subLists

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 7
    • Affects Version/s: 7
    • Component/s: core-libs
    • None

      This program:

      public class Bug34 {
          public static void main(String[] args) throws Throwable {
      java.util.List x
      = new java.util.concurrent.CopyOnWriteArrayList().subList(0,0);
      x.add("foo");
      x.remove("foo");
      assert(x.isEmpty());
          }
      }

      throws

      Exception in thread "main" java.lang.UnsupportedOperationException
      at java.util.concurrent.CopyOnWriteArrayList$COWSubListIterator.remove(CopyOnWriteArrayList.java:1297)
      at java.util.AbstractCollection.remove(AbstractCollection.java:270)
      at Bug34.main(Bug34.java:6)

      which violates the invariant that if add(x) succeeds, then remove(x) should as well.
      Also, that if remove(int) is supported, then remove(Object) should also be.

            Assignee:
            Martin Buchholz
            Reporter:
            Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: