8174950: Gracefully handle null Supplier in Objects.requireNonNull

Reviewed-by: dholmes, psandoz, alanb, chegar
This commit is contained in:
Volker Simonis 2017-02-15 09:10:24 +01:00
parent cb48e2096d
commit 46cd380010

@ -343,7 +343,8 @@ public final class Objects {
*/
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;
}