Skip to content

Commit 9af7027

Browse files
committed
Allow messageSupplier to be null.
The docs at best indirectly imply that it can be `null`: They have a `@throws NullPointerException` clause that mentions only the case in which `obj` is `null`, without saying anything similar about `messageSupplier`. But of course I'm actually going mostly off the implementation.... (Note that this PR is separate from #104, which describes *another* change that we could make to this parameter.)
1 parent 457b292 commit 9af7027

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/java.base/share/classes/java/util/Objects.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public static <T> T requireNonNullElseGet(@Nullable T obj, Supplier<? extends @N
354354
*/
355355

356356

357-
public static <T> T requireNonNull( @Nullable T obj, Supplier<String> messageSupplier) {
357+
public static <T> T requireNonNull( @Nullable T obj, @Nullable Supplier<String> messageSupplier) {
358358
if (obj == null)
359359
throw new NullPointerException(messageSupplier == null ?
360360
null : messageSupplier.get());

0 commit comments

Comments
 (0)