Skip to content

Commit

Permalink
ListObjects(): fix parsing user metadata as per MinIO server (#1369)
Browse files Browse the repository at this point in the history
Fixes #1368

Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana committed Sep 24, 2022
1 parent 1041f87 commit f909b02
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions api/src/main/java/io/minio/messages/Item.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2015-2021 MinIO, Inc.
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2015-2022 MinIO, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,8 +20,12 @@
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Path;

/**
* Helper class to denote Object information in {@link ListBucketResultV1}, {@link
Expand Down Expand Up @@ -54,8 +58,15 @@ public abstract class Item {
@Element(name = "VersionId", required = false)
private String versionId; // except ListObjects V1

@Element(name = "UserMetadata", required = false)
private Metadata userMetadata;
@Path(value = "UserMetadata")
@ElementMap(
attribute = false,
entry = "Items",
inline = true,
key = "Key",
value = "Value",
required = false)
private Map<String, String> userMetadata;

private boolean isDir = false;
private String encodingType = null;
Expand Down Expand Up @@ -108,7 +119,7 @@ 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 Collections.unmodifiableMap(userMetadata == null ? new HashMap<>() : userMetadata);
}

/** Returns whether this version ID is latest. */
Expand Down

0 comments on commit f909b02

Please sign in to comment.