diff --git a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java index 4ac11a32bfa..db8aa1ebeba 100644 --- a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java @@ -78,7 +78,7 @@ public abstract class ObjectUtils { /** * Check whether the given exception is compatible with the specified - * exception types, as declared in a throws clause. + * exception types, as declared in a {@code throws} clause. * @param ex the exception to check * @param declaredExceptions the exception types declared in the throws clause * @return whether the given exception is compatible @@ -143,7 +143,7 @@ public abstract class ObjectUtils { } if (obj instanceof Optional optional) { - return !optional.isPresent(); + return optional.isEmpty(); } if (obj instanceof CharSequence charSequence) { return charSequence.length() == 0; @@ -172,7 +172,7 @@ public abstract class ObjectUtils { @Nullable public static Object unwrapOptional(@Nullable Object obj) { if (obj instanceof Optional optional) { - if (!optional.isPresent()) { + if (optional.isEmpty()) { return null; } Object result = optional.get(); @@ -900,10 +900,10 @@ public abstract class ObjectUtils { *

Returns: *