Skip to content

Commit f669c5b

Browse files
cpovirkwmdietl
andauthored
Allow messageSupplier to be null. (#105)
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.) Co-authored-by: Werner Dietl <[email protected]>
1 parent c9befbc commit f669c5b

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
@@ -351,7 +351,7 @@ public static <T> T requireNonNullElseGet(@Nullable T obj, Supplier<? extends @N
351351
* @throws NullPointerException if {@code obj} is {@code null}
352352
* @since 1.8
353353
*/
354-
public static <T> T requireNonNull(@Nullable T obj, Supplier<String> messageSupplier) {
354+
public static <T> T requireNonNull(@Nullable T obj, @Nullable Supplier<String> messageSupplier) {
355355
if (obj == null)
356356
throw new NullPointerException(messageSupplier == null ?
357357
null : messageSupplier.get());

0 commit comments

Comments
 (0)