Skip to content

Commit

Permalink
Guard against NullPointerException for null Item.lastModified.
Browse files Browse the repository at this point in the history
  • Loading branch information
hwaite committed Dec 21, 2024
1 parent e16ddbe commit 658778d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/src/main/java/io/minio/messages/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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. */
Expand All @@ -111,7 +114,9 @@ public Owner owner() {

/** Returns user metadata. This is MinIO specific extension to ListObjectsV2. */
public Map<String, String> userMetadata() {
return (userMetadata == null) ? null : userMetadata.get();
return Optional.ofNullable(userMetadata)
.map(Metadata::get)
.orElse(null);
}

public String userTags() {
Expand Down

0 comments on commit 658778d

Please sign in to comment.