Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle null value in io.minio.messages.Item.lastModified() method #1605

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
balamurugana marked this conversation as resolved.
Show resolved Hide resolved
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)
balamurugana marked this conversation as resolved.
Show resolved Hide resolved
.map(ResponseDate::zonedDateTime)
.orElse(null);
balamurugana marked this conversation as resolved.
Show resolved Hide resolved
}

/** 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);
balamurugana marked this conversation as resolved.
Show resolved Hide resolved
balamurugana marked this conversation as resolved.
Show resolved Hide resolved
}

public String userTags() {
Expand Down