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 10df5e7  Make most LedgerMetadata fields final
10df5e7 is described below

commit 10df5e7f0f5b6554844f378757edd24e1f3b2fab
Author: Ivan Kelly <[email protected]>
AuthorDate: Thu Nov 22 17:45:48 2018 +0000

    Make most LedgerMetadata fields final
    
    Make most fields in LedgerMetadata final. The ones which I have not
    changed in this patch require a more involved change, so they'll come
    in separate PRs.
    
    Master issue: #281
    
    
    Reviewers: Enrico Olivelli <[email protected]>
    
    This closes #1828 from ivankelly/mostly-final
---
 .../apache/bookkeeper/client/LedgerMetadata.java   | 30 ++++++++++++----------
 1 file changed, 16 insertions(+), 14 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 5fd5f06..026cc97 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
@@ -72,22 +72,22 @@ public class LedgerMetadata implements 
org.apache.bookkeeper.client.api.LedgerMe
     public static final int CURRENT_METADATA_FORMAT_VERSION = 2;
     public static final String VERSION_KEY = "BookieMetadataFormatVersion";
 
-    private int metadataFormatVersion = 0;
-    private int ensembleSize;
-    private int writeQuorumSize;
-    private int ackQuorumSize;
+    private final int metadataFormatVersion;
+    private final int ensembleSize;
+    private final int writeQuorumSize;
+    private final int ackQuorumSize;
     private long length;
     private long lastEntryId;
-    private long ctime;
-    boolean storeCtime; // non-private so builder can access for copy
+    private final long ctime;
+    final boolean storeCtime; // non-private so builder can access for copy
 
     private LedgerMetadataFormat.State state;
     private TreeMap<Long, ImmutableList<BookieSocketAddress>> ensembles =  new 
TreeMap<>();
     private List<BookieSocketAddress> currentEnsemble;
 
-    private boolean hasPassword = false;
-    private LedgerMetadataFormat.DigestType digestType;
-    private byte[] password;
+    private final boolean hasPassword; // IKTODO other things should be 
optionals instead
+    private final LedgerMetadataFormat.DigestType digestType;
+    private final byte[] password;
 
     private Map<String, byte[]> customMetadata = Maps.newHashMap();
 
@@ -126,11 +126,13 @@ public class LedgerMetadata implements 
org.apache.bookkeeper.client.api.LedgerMe
         this.digestType = digestType.equals(DigestType.MAC)
             ? LedgerMetadataFormat.DigestType.HMAC : 
LedgerMetadataFormat.DigestType.valueOf(digestType.toString());
 
-        password.ifPresent((pw) -> {
-                this.password = pw;
-                this.hasPassword = true;
-            });
-
+        if (password.isPresent()) {
+            this.password = password.get();
+            this.hasPassword = true;
+        } else {
+            this.password = null;
+            this.hasPassword = false;
+        }
         this.ctime = ctime;
         this.storeCtime = storeCtime;
 

Reply via email to