changeset 16736:8fd1fcfc2f09

8174950: Gracefully handle null Supplier in Objects.requireNonNull Reviewed-by: dholmes, psandoz, alanb, chegar
author simonis
date Wed, 15 Feb 2017 09:10:24 +0100
parents 734a8b392154
children 8b0d55e02f54
files src/java.base/share/classes/java/util/Objects.java
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/Objects.java	Wed Feb 15 09:08:25 2017 +0800
+++ b/src/java.base/share/classes/java/util/Objects.java	Wed Feb 15 09:10:24 2017 +0100
@@ -343,7 +343,8 @@
      */
     public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) {
         if (obj == null)
-            throw new NullPointerException(messageSupplier.get());
+            throw new NullPointerException(messageSupplier == null ?
+                                           null : messageSupplier.get());
         return obj;
     }