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

Comparing jsr166/src/main/java/util/concurrent/ArrayBlockingQueue.java (file contents):
Revision 1.118 by jsr166, Fri Feb 20 21:38:43 2015 UTC vs.
Revision 1.119 by jsr166, Sat Feb 21 17:15:00 2015 UTC

# Line 11 | Line 11 | import java.util.AbstractQueue;
11   import java.util.Collection;
12   import java.util.Iterator;
13   import java.util.NoSuchElementException;
14 + import java.util.Objects;
15   import java.util.Spliterator;
16   import java.util.Spliterators;
17   import java.util.concurrent.locks.Condition;
# Line 113 | Line 114 | public class ArrayBlockingQueue<E> exten
114      }
115  
116      /**
116     * Throws NullPointerException if argument is null.
117     *
118     * @param v the element
119     */
120    private static void checkNotNull(Object v) {
121        if (v == null)
122            throw new NullPointerException();
123    }
124
125    /**
117       * Inserts element at current put position, advances, and signals.
118       * Call only when holding lock.
119       */
# Line 248 | Line 239 | public class ArrayBlockingQueue<E> exten
239          try {
240              int i = 0;
241              try {
242 <                for (E e : c) {
243 <                    checkNotNull(e);
253 <                    items[i++] = e;
254 <                }
242 >                for (E e : c)
243 >                    items[i++] = Objects.requireNonNull(e);
244              } catch (ArrayIndexOutOfBoundsException ex) {
245                  throw new IllegalArgumentException();
246              }
# Line 287 | Line 276 | public class ArrayBlockingQueue<E> exten
276       * @throws NullPointerException if the specified element is null
277       */
278      public boolean offer(E e) {
279 <        checkNotNull(e);
279 >        Objects.requireNonNull(e);
280          final ReentrantLock lock = this.lock;
281          lock.lock();
282          try {
# Line 310 | Line 299 | public class ArrayBlockingQueue<E> exten
299       * @throws NullPointerException {@inheritDoc}
300       */
301      public void put(E e) throws InterruptedException {
302 <        checkNotNull(e);
302 >        Objects.requireNonNull(e);
303          final ReentrantLock lock = this.lock;
304          lock.lockInterruptibly();
305          try {
# Line 333 | Line 322 | public class ArrayBlockingQueue<E> exten
322      public boolean offer(E e, long timeout, TimeUnit unit)
323          throws InterruptedException {
324  
325 <        checkNotNull(e);
325 >        Objects.requireNonNull(e);
326          long nanos = unit.toNanos(timeout);
327          final ReentrantLock lock = this.lock;
328          lock.lockInterruptibly();
# Line 667 | Line 656 | public class ArrayBlockingQueue<E> exten
656       * @throws IllegalArgumentException      {@inheritDoc}
657       */
658      public int drainTo(Collection<? super E> c, int maxElements) {
659 <        checkNotNull(c);
659 >        Objects.requireNonNull(c);
660          if (c == this)
661              throw new IllegalArgumentException();
662          if (maxElements <= 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines