We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1c87e47 commit fc8bd64Copy full SHA for fc8bd64
spring-core/src/main/java/org/springframework/util/ObjectUtils.java
@@ -173,10 +173,7 @@ public static boolean isEmpty(@Nullable Object obj) {
173
@Nullable
174
public static Object unwrapOptional(@Nullable Object obj) {
175
if (obj instanceof Optional<?> optional) {
176
- if (optional.isEmpty()) {
177
- return null;
178
- }
179
- Object result = optional.get();
+ Object result = optional.orElse(null);
180
Assert.isTrue(!(result instanceof Optional), "Multi-level Optional usage not supported");
181
return result;
182
}
0 commit comments