changeset 9918:c7077bc04f1e

Merge
author coffeys
date Wed, 30 Jul 2014 18:09:54 +0100
parents d888ef204713 6c7c3a54777f
children dd229c5f57bf
files
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/Collections.java	Mon Jul 28 07:23:51 2014 -0700
+++ b/src/share/classes/java/util/Collections.java	Wed Jul 30 18:09:54 2014 +0100
@@ -3497,6 +3497,7 @@
          */
         @Override
         public void replaceAll(UnaryOperator<E> operator) {
+            Objects.requireNonNull(operator);
             list.replaceAll(e -> typeCheck(operator.apply(e)));
         }
 
--- a/test/java/util/Collections/CheckedListReplaceAll.java	Mon Jul 28 07:23:51 2014 -0700
+++ b/test/java/util/Collections/CheckedListReplaceAll.java	Wed Jul 30 18:09:54 2014 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug     8047795
+ * @bug     8047795 8053938
  * @summary Ensure that replaceAll operator cannot add bad elements
  * @author  Mike Duigou
  */
@@ -46,5 +46,16 @@
             thwarted.printStackTrace(System.out);
             System.out.println("Curses! Foiled again!");
         }
+
+        unwrapped = Arrays.asList(new Object[]{});  // Empty list
+        wrapped = Collections.checkedList(unwrapped, Integer.class);
+        try {
+            wrapped.replaceAll((UnaryOperator)null);
+            System.out.printf("Bwahaha! I have defeated you! %s\n", wrapped);
+            throw new RuntimeException("NPE not thrown when passed a null operator");
+        } catch (NullPointerException thwarted) {
+            thwarted.printStackTrace(System.out);
+            System.out.println("Curses! Foiled again!");
+        }
     }
 }