ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CopyOnWriteArrayList.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CopyOnWriteArrayList.java (file contents):
Revision 1.124 by jsr166, Sun Jan 25 20:07:01 2015 UTC vs.
Revision 1.125 by jsr166, Sun Jan 25 20:37:11 2015 UTC

# Line 370 | Line 370 | public class CopyOnWriteArrayList<E>
370          return (E) a[index];
371      }
372  
373 +    static String outOfBounds(int index, int size) {
374 +        return "Index: " + index + ", Size: " + size;
375 +    }
376 +
377      /**
378       * {@inheritDoc}
379       *
# Line 432 | Line 436 | public class CopyOnWriteArrayList<E>
436              Object[] elements = getArray();
437              int len = elements.length;
438              if (index > len || index < 0)
439 <                throw new IndexOutOfBoundsException("Index: "+index+
436 <                                                    ", Size: "+len);
439 >                throw new IndexOutOfBoundsException(outOfBounds(index, len));
440              Object[] newElements;
441              int numMoved = len - index;
442              if (numMoved == 0)
# Line 790 | Line 793 | public class CopyOnWriteArrayList<E>
793              Object[] elements = getArray();
794              int len = elements.length;
795              if (index > len || index < 0)
796 <                throw new IndexOutOfBoundsException("Index: "+index+
794 <                                                    ", Size: "+len);
796 >                throw new IndexOutOfBoundsException(outOfBounds(index, len));
797              if (cs.length == 0)
798                  return false;
799              int numMoved = len - index;
# Line 1020 | Line 1022 | public class CopyOnWriteArrayList<E>
1022          Object[] elements = getArray();
1023          int len = elements.length;
1024          if (index < 0 || index > len)
1025 <            throw new IndexOutOfBoundsException("Index: "+index);
1025 >            throw new IndexOutOfBoundsException(outOfBounds(index, len));
1026  
1027          return new COWIterator<E>(elements, index);
1028      }
# Line 1184 | Line 1186 | public class CopyOnWriteArrayList<E>
1186          private void rangeCheck(int index) {
1187              // assert Thread.holdsLock(l.lock);
1188              if (index < 0 || index >= size)
1189 <                throw new IndexOutOfBoundsException("Index: "+index+
1188 <                                                    ",Size: "+size);
1189 >                throw new IndexOutOfBoundsException(outOfBounds(index, size));
1190          }
1191  
1192          public E set(int index, E element) {
# Line 1217 | Line 1218 | public class CopyOnWriteArrayList<E>
1218              synchronized (l.lock) {
1219                  checkForComodification();
1220                  if (index < 0 || index > size)
1221 <                    throw new IndexOutOfBoundsException();
1221 >                    throw new IndexOutOfBoundsException
1222 >                        (outOfBounds(index, size));
1223                  l.add(index+offset, element);
1224                  expectedArray = l.getArray();
1225                  size++;
# Line 1263 | Line 1265 | public class CopyOnWriteArrayList<E>
1265              synchronized (l.lock) {
1266                  checkForComodification();
1267                  if (index < 0 || index > size)
1268 <                    throw new IndexOutOfBoundsException("Index: "+index+
1269 <                                                        ", Size: "+size);
1268 >                    throw new IndexOutOfBoundsException
1269 >                        (outOfBounds(index, size));
1270                  return new COWSubListIterator<E>(l, index, offset, size);
1271              }
1272          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines