8174950: Gracefully handle null Supplier in Objects.requireNonNull
Reviewed-by: dholmes, psandoz, alanb, chegar
--- a/jdk/src/java.base/share/classes/java/util/Objects.java Wed Feb 15 09:08:25 2017 +0800
+++ b/jdk/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;
}