changeset 13330:86e5434d384b

8145006: Collections.asLifoQueue(null) doesn't throw NPE as specified Reviewed-by: smarks
author psandoz
date Fri, 18 Dec 2015 09:59:25 +0100
parents 429f1bfacb54
children 7c94f332ea1c
files src/java.base/share/classes/java/util/Collections.java test/java/util/Collections/AsLifoQueue.java
diffstat 2 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/Collections.java	Thu Dec 17 20:27:37 2015 -0800
+++ b/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/test/java/util/Collections/AsLifoQueue.java	Thu Dec 17 20:27:37 2015 -0800
+++ b/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 ---------------------------