in hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/Preconditions.java [138:157]
public static <T> T checkNotNull(final T obj,
final Supplier<String> msgSupplier) {
if (obj == null) {
String msg;
try {
// note that we can get NPE evaluating the message itself;
// but we do not want this to override the actual NPE.
msg = msgSupplier.get();
} catch (Exception e) {
// ideally we want to log the error to capture. This may cause log files
// to bloat. On the other hand, swallowing the exception may hide a bug
// in the caller. Debug level is a good compromise between the two
// concerns.
LOG.debug("Error formatting message", e);
msg = VALIDATE_IS_NOT_NULL_EX_MESSAGE;
}
throw new NullPointerException(msg);
}
return obj;
}