From 658778d12bfb0b255329bdada6140f536654ed49 Mon Sep 17 00:00:00 2001 From: Hollis Waite Date: Sat, 21 Dec 2024 13:04:40 -0500 Subject: [PATCH] Guard against NullPointerException for null Item.lastModified. --- api/src/main/java/io/minio/messages/Item.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/io/minio/messages/Item.java b/api/src/main/java/io/minio/messages/Item.java index 7bca672ca..c4552a265 100644 --- a/api/src/main/java/io/minio/messages/Item.java +++ b/api/src/main/java/io/minio/messages/Item.java @@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets; import java.time.ZonedDateTime; import java.util.Map; +import java.util.Optional; import org.simpleframework.xml.Element; /** @@ -86,7 +87,9 @@ public String objectName() { /** Returns last modified time of the object. */ public ZonedDateTime lastModified() { - return lastModified.zonedDateTime(); + return Optional.ofNullable(lastModified) + .map(ResponseDate::zonedDateTime) + .orElse(null); } /** Returns ETag of the object. */ @@ -111,7 +114,9 @@ public Owner owner() { /** Returns user metadata. This is MinIO specific extension to ListObjectsV2. */ public Map userMetadata() { - return (userMetadata == null) ? null : userMetadata.get(); + return Optional.ofNullable(userMetadata) + .map(Metadata::get) + .orElse(null); } public String userTags() {