src/share/classes/java/util/Objects.java
Print this page
rev 9262 : 8033909: Objects.requireNonNull(T, Supplier) doesn't specify what happens if the passed supplier is null itself
*** 285,293 ****
* @throws NullPointerException if {@code obj} is {@code null}
* @since 1.8
*/
public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) {
if (obj == null)
! throw new NullPointerException(messageSupplier.get());
return obj;
}
}
--- 285,294 ----
* @throws NullPointerException if {@code obj} is {@code null}
* @since 1.8
*/
public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) {
if (obj == null)
! throw new NullPointerException(messageSupplier == null ?
! null : messageSupplier.get());
return obj;
}
}