This is an automated email from the ASF dual-hosted git repository.
ivank pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 4019f75 Make custom metadata final
4019f75 is described below
commit 4019f75536d99d4af85269221811f2e41d4f8fae
Author: Ivan Kelly <[email protected]>
AuthorDate: Fri Nov 23 18:50:47 2018 +0000
Make custom metadata final
Master issue: #281
Reviewers: Enrico Olivelli <[email protected]>
This closes #1833 from ivankelly/immut-cust
---
.../java/org/apache/bookkeeper/client/LedgerMetadata.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
index 6094df2..514f1af 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
@@ -23,7 +23,7 @@ import static com.google.common.base.Preconditions.checkState;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
+import com.google.common.collect.ImmutableMap;
import com.google.protobuf.ByteString;
import com.google.protobuf.TextFormat;
import java.io.BufferedReader;
@@ -87,11 +87,11 @@ public class LedgerMetadata implements
org.apache.bookkeeper.client.api.LedgerMe
private final NavigableMap<Long, ImmutableList<BookieSocketAddress>>
ensembles;
private final ImmutableList<BookieSocketAddress> currentEnsemble;
- private final boolean hasPassword; // IKTODO other things should be
optionals instead
+ private final boolean hasPassword;
private final LedgerMetadataFormat.DigestType digestType;
private final byte[] password;
- private Map<String, byte[]> customMetadata = Maps.newHashMap();
+ private final Map<String, byte[]> customMetadata;
LedgerMetadata(int metadataFormatVersion,
int ensembleSize,
@@ -149,7 +149,7 @@ public class LedgerMetadata implements
org.apache.bookkeeper.client.api.LedgerMe
this.ctime = ctime;
this.storeCtime = storeCtime;
- this.customMetadata.putAll(customMetadata);
+ this.customMetadata = ImmutableMap.copyOf(customMetadata);
}
@Override
@@ -272,10 +272,6 @@ public class LedgerMetadata implements
org.apache.bookkeeper.client.api.LedgerMe
return this.customMetadata;
}
- void setCustomMetadata(Map<String, byte[]> customMetadata) {
- this.customMetadata = customMetadata;
- }
-
LedgerMetadataFormat buildProtoFormat() {
return buildProtoFormat(true);
}