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() {