8145006: Collections.asLifoQueue(null) doesn't throw NPE as specified
authorpsandoz
Fri, 18 Dec 2015 09:59:25 +0100
changeset 34714 2637c9a952c2
parent 34713 a89d6429ed35
child 34715 efac989a60dd
8145006: Collections.asLifoQueue(null) doesn't throw NPE as specified Reviewed-by: smarks
jdk/src/java.base/share/classes/java/util/Collections.java
jdk/test/java/util/Collections/AsLifoQueue.java
--- a/jdk/src/java.base/share/classes/java/util/Collections.java	Thu Dec 17 20:27:37 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/Collections.java	Fri Dec 18 09:59:25 2015 +0100
@@ -5530,7 +5530,7 @@
      * @since  1.6
      */
     public static <T> Queue<T> asLifoQueue(Deque<T> deque) {
-        return new AsLIFOQueue<>(deque);
+        return new AsLIFOQueue<>(Objects.requireNonNull(deque));
     }
 
     /**
--- a/jdk/test/java/util/Collections/AsLifoQueue.java	Thu Dec 17 20:27:37 2015 -0800
+++ b/jdk/test/java/util/Collections/AsLifoQueue.java	Fri Dec 18 09:59:25 2015 +0100
@@ -70,6 +70,8 @@
             check(q.isEmpty());
             equal(q.size(), 0);
         } catch (Throwable t) { unexpected(t); }
+
+        THROWS(NullPointerException.class, () -> Collections.asLifoQueue(null));
     }
 
     //--------------------- Infrastructure ---------------------------