bookkeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mme...@apache.org
Subject bookkeeper git commit: BOOKKEEPER-940: Fix findbugs warnings after bumping to java 8
Date Thu, 14 Jul 2016 21:02:46 GMT
Repository: bookkeeper
Updated Branches:
  refs/heads/master 2506c98f8 -> 2f71beb5e


BOOKKEEPER-940: Fix findbugs warnings after bumping to java 8

Author: eolivelli <eolivelli@gmail.com>

Reviewers: Matteo Merli <mmerli@apache.org>, Sijie Guo <sijie@apache.org>

Closes #55 from eolivelli/BOOKKEEPER-940


Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/2f71beb5
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/2f71beb5
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/2f71beb5

Branch: refs/heads/master
Commit: 2f71beb5e4b06691d4fd6c2601b78632236b3533
Parents: 2506c98
Author: eolivelli <eolivelli@gmail.com>
Authored: Thu Jul 14 14:02:33 2016 -0700
Committer: Matteo Merli <mmerli@apache.org>
Committed: Thu Jul 14 14:02:33 2016 -0700

----------------------------------------------------------------------
 .../bookkeeper/benchmark/BenchBookie.java       |  4 +--
 .../benchmark/BenchReadThroughputLatency.java   | 10 +++----
 .../benchmark/BenchThroughputLatency.java       | 20 +++++++-------
 .../apache/bookkeeper/benchmark/TestClient.java | 14 +++++-----
 .../org/apache/bookkeeper/bookie/Bookie.java    | 18 ++++++++-----
 .../apache/bookkeeper/bookie/EntryLogger.java   | 14 +++++-----
 .../bookkeeper/bookie/FileSystemUpgrade.java    | 28 ++++++++++++--------
 .../bookie/GarbageCollectorThread.java          |  5 ++--
 .../bookkeeper/bookie/IndexPersistenceMgr.java  | 18 ++++++++++---
 .../org/apache/bookkeeper/bookie/Journal.java   |  3 +++
 .../bookkeeper/client/BookKeeperAdmin.java      |  3 +++
 .../bookkeeper/client/LedgerMetadata.java       | 16 +++++------
 .../apache/bookkeeper/meta/LedgerLayout.java    |  4 +--
 .../meta/ZkLedgerUnderreplicationManager.java   |  2 +-
 .../bookkeeper/metastore/MetastoreTable.java    |  4 +--
 .../org/apache/bookkeeper/metastore/Value.java  |  5 ++--
 .../bookkeeper/replication/AuditorElector.java  |  2 +-
 17 files changed, 101 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
----------------------------------------------------------------------
diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
index 89ffb82..94ffd02 100644
--- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
+++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
@@ -133,8 +133,8 @@ public class BenchBookie {
         }
 
         String addr = cmd.getOptionValue("host");
-        int port = Integer.valueOf(cmd.getOptionValue("port", "3181"));
-        int size = Integer.valueOf(cmd.getOptionValue("size", "1024"));
+        int port = Integer.parseInt(cmd.getOptionValue("port", "3181"));
+        int size = Integer.parseInt(cmd.getOptionValue("size", "1024"));
         String servers = cmd.getOptionValue("zookeeper", "localhost:2181");
 
 

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
----------------------------------------------------------------------
diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
index 1cdd564..f04960a 100644
--- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
+++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
@@ -58,8 +58,8 @@ public class BenchReadThroughputLatency {
                 Matcher m1 = LEDGER_PATTERN.matcher(o1);
                 Matcher m2 = LEDGER_PATTERN.matcher(o2);
                 if (m1.find() && m2.find()) {
-                    return Integer.valueOf(m1.group(1))
-                        - Integer.valueOf(m2.group(1));
+                    return Integer.parseInt(m1.group(1))
+                        - Integer.parseInt(m2.group(1));
                 } else {
                     return o1.compareTo(o2);
                 }
@@ -164,7 +164,7 @@ public class BenchReadThroughputLatency {
 
         final String servers = cmd.getOptionValue("zookeeper", "localhost:2181");
         final byte[] passwd = cmd.getOptionValue("password", "benchPasswd").getBytes(UTF_8);
-        final int sockTimeout = Integer.valueOf(cmd.getOptionValue("sockettimeout", "5"));
+        final int sockTimeout = Integer.parseInt(cmd.getOptionValue("sockettimeout", "5"));
         if (cmd.hasOption("ledger") && cmd.hasOption("listen")) {
             LOG.error("Cannot used -ledger and -listen together");
             usage(options);
@@ -174,9 +174,9 @@ public class BenchReadThroughputLatency {
         final AtomicInteger ledger = new AtomicInteger(0);
         final AtomicInteger numLedgers = new AtomicInteger(0);
         if (cmd.hasOption("ledger")) {
-            ledger.set(Integer.valueOf(cmd.getOptionValue("ledger")));
+            ledger.set(Integer.parseInt(cmd.getOptionValue("ledger")));
         } else if (cmd.hasOption("listen")) {
-            numLedgers.set(Integer.valueOf(cmd.getOptionValue("listen")));
+            numLedgers.set(Integer.parseInt(cmd.getOptionValue("listen")));
         } else {
             LOG.error("You must use -ledger or -listen");
             usage(options);

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
----------------------------------------------------------------------
diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
index 4a21792..b121944 100644
--- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
+++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
@@ -260,21 +260,21 @@ public class BenchThroughputLatency implements AddCallback, Runnable
{
             System.exit(-1);
         }
 
-        long runningTime = Long.valueOf(cmd.getOptionValue("time", "60"));
+        long runningTime = Long.parseLong(cmd.getOptionValue("time", "60"));
         String servers = cmd.getOptionValue("zookeeper", "localhost:2181");
-        int entrysize = Integer.valueOf(cmd.getOptionValue("entrysize", "1024"));
+        int entrysize = Integer.parseInt(cmd.getOptionValue("entrysize", "1024"));
 
-        int ledgers = Integer.valueOf(cmd.getOptionValue("ledgers", "1"));
-        int ensemble = Integer.valueOf(cmd.getOptionValue("ensemble", "3"));
-        int quorum = Integer.valueOf(cmd.getOptionValue("quorum", "2"));
+        int ledgers = Integer.parseInt(cmd.getOptionValue("ledgers", "1"));
+        int ensemble = Integer.parseInt(cmd.getOptionValue("ensemble", "3"));
+        int quorum = Integer.parseInt(cmd.getOptionValue("quorum", "2"));
         int ackQuorum = quorum;
         if (cmd.hasOption("ackQuorum")) {
-            ackQuorum = Integer.valueOf(cmd.getOptionValue("ackQuorum"));
+            ackQuorum = Integer.parseInt(cmd.getOptionValue("ackQuorum"));
         }
-        int throttle = Integer.valueOf(cmd.getOptionValue("throttle", "10000"));
-        int sendLimit = Integer.valueOf(cmd.getOptionValue("sendlimit", "20000000"));
+        int throttle = Integer.parseInt(cmd.getOptionValue("throttle", "10000"));
+        int sendLimit = Integer.parseInt(cmd.getOptionValue("sendlimit", "20000000"));
 
-        final int sockTimeout = Integer.valueOf(cmd.getOptionValue("sockettimeout", "5"));
+        final int sockTimeout = Integer.parseInt(cmd.getOptionValue("sockettimeout", "5"));
 
         String coordinationZnode = cmd.getOptionValue("coordnode");
         final byte[] passwd = cmd.getOptionValue("password", "benchPasswd").getBytes(UTF_8);
@@ -283,7 +283,7 @@ public class BenchThroughputLatency implements AddCallback, Runnable {
 
         Timer timeouter = new Timer();
         if (cmd.hasOption("timeout")) {
-            final long timeout = Long.valueOf(cmd.getOptionValue("timeout", "360")) * 1000;
+            final long timeout = Long.parseLong(cmd.getOptionValue("timeout", "360")) * 1000;
 
             timeouter.schedule(new TimerTask() {
                     public void run() {

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
----------------------------------------------------------------------
diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
index b64151c..a974553 100644
--- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
+++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
@@ -97,9 +97,9 @@ public class TestClient {
             System.exit(-1);
         }
 
-        int length = Integer.valueOf(cmd.getOptionValue("length", "1024"));
+        int length = Integer.parseInt(cmd.getOptionValue("length", "1024"));
         String target = cmd.getOptionValue("target", "fs");
-        long runfor = Long.valueOf(cmd.getOptionValue("runfor", "60")) * 1000;
+        long runfor = Long.parseLong(cmd.getOptionValue("runfor", "60")) * 1000;
 
         StringBuilder sb = new StringBuilder();
         while(length-- > 0) {
@@ -108,7 +108,7 @@ public class TestClient {
 
         Timer timeouter = new Timer();
         if (cmd.hasOption("timeout")) {
-            final long timeout = Long.valueOf(cmd.getOptionValue("timeout", "360")) * 1000;
+            final long timeout = Long.parseLong(cmd.getOptionValue("timeout", "360")) * 1000;
 
             timeouter.schedule(new TimerTask() {
                     public void run() {
@@ -120,7 +120,7 @@ public class TestClient {
 
         BookKeeper bkc = null;
         try {
-            int numFiles = Integer.valueOf(cmd.getOptionValue("numconcurrent", "1"));
+            int numFiles = Integer.parseInt(cmd.getOptionValue("numconcurrent", "1"));
             int numThreads = Math.min(numFiles, 1000);
             byte[] data = sb.toString().getBytes(UTF_8);
             long runid = System.currentTimeMillis();
@@ -128,9 +128,9 @@ public class TestClient {
 
             if (target.equals("bk")) {
                 String zkservers = cmd.getOptionValue("zkservers", "localhost:2181");
-                int bkensemble = Integer.valueOf(cmd.getOptionValue("bkensemble", "3"));
-                int bkquorum = Integer.valueOf(cmd.getOptionValue("bkquorum", "2"));
-                int bkthrottle = Integer.valueOf(cmd.getOptionValue("bkthrottle", "10000"));
+                int bkensemble = Integer.parseInt(cmd.getOptionValue("bkensemble", "3"));
+                int bkquorum = Integer.parseInt(cmd.getOptionValue("bkquorum", "2"));
+                int bkthrottle = Integer.parseInt(cmd.getOptionValue("bkthrottle", "10000"));
 
                 ClientConfiguration conf = new ClientConfiguration();
                 conf.setThrottleValue(bkthrottle);

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
index 6272200..178f2bb 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
@@ -1344,8 +1344,9 @@ public class Bookie extends BookieCriticalThread {
     public static boolean format(ServerConfiguration conf,
             boolean isInteractive, boolean force) {
         File journalDir = conf.getJournalDir();
-        if (journalDir.exists() && journalDir.isDirectory()
-                && journalDir.list().length != 0) {
+        String[] journalDirFiles =
+                journalDir.exists() && journalDir.isDirectory() ? journalDir.list()
: null;
+        if (journalDirFiles != null && journalDirFiles.length != 0) {
             try {
                 boolean confirm = false;
                 if (!isInteractive) {
@@ -1400,11 +1401,14 @@ public class Bookie extends BookieCriticalThread {
 
     private static boolean cleanDir(File dir) {
         if (dir.exists()) {
-            for (File child : dir.listFiles()) {
-                boolean delete = FileUtils.deleteQuietly(child);
-                if (!delete) {
-                    LOG.error("Not able to delete " + child);
-                    return false;
+            File[] files = dir.listFiles();
+            if (files != null) {
+                for (File child : files) {
+                    boolean delete = FileUtils.deleteQuietly(child);
+                    if (!delete) {
+                        LOG.error("Not able to delete " + child);
+                        return false;
+                    }
                 }
             }
         } else if (!dir.mkdirs()) {

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
index a970a96..ecd0e0a 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
@@ -651,12 +651,14 @@ public class EntryLogger {
             }
         });
         List<Long> logs = new ArrayList<Long>();
-        for (File lf : logFiles) {
-            String idString = lf.getName().split("\\.")[0];
-            try {
-                long lid = Long.parseLong(idString, 16);
-                logs.add(lid);
-            } catch (NumberFormatException nfe) {
+        if (logFiles != null) {
+            for (File lf : logFiles) {
+                String idString = lf.getName().split("\\.")[0];
+                try {
+                    long lid = Long.parseLong(idString, 16);
+                    logs.add(lid);
+                } catch (NumberFormatException nfe) {
+                }
             }
         }
         // no log file found in this directory

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileSystemUpgrade.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileSystemUpgrade.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileSystemUpgrade.java
index 4ec3add..177270e 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileSystemUpgrade.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileSystemUpgrade.java
@@ -70,9 +70,11 @@ public class FileSystemUpgrade {
                     File d = new File(dir, name);
                     if (d.isDirectory()) {
                         String[] files = d.list();
-                        for (String f : files) {
-                            if (containsIndexFiles(d, f)) {
-                                return true;
+                        if (files != null) {
+                            for (String f : files) {
+                                if (containsIndexFiles(d, f)) {
+                                    return true;
+                                }
                             }
                         }
                     }
@@ -107,7 +109,7 @@ public class FileSystemUpgrade {
         String[] files = directory.list(BOOKIE_FILES_FILTER);
         File v2versionFile = new File(directory,
                 BookKeeperConstants.VERSION_FILENAME);
-        if (files.length == 0 && !v2versionFile.exists()) { // no old data, so we're
ok
+        if ((files == null || files.length == 0) && !v2versionFile.exists()) { //
no old data, so we're ok
             return Cookie.CURRENT_COOKIE_LAYOUT_VERSION;
         }
 
@@ -149,7 +151,9 @@ public class FileSystemUpgrade {
 
     private static void linkIndexDirectories(File srcPath, File targetPath) throws IOException
{
         String[] files = srcPath.list();
-
+        if (files == null) {
+            return;
+        }
         for (String f : files) {
             if (f.endsWith(".idx")) { // this is an index dir, create the links
                 if (!targetPath.mkdirs()) {
@@ -257,12 +261,14 @@ public class FileSystemUpgrade {
                         }
                     }
                     File[] files = d.listFiles(BOOKIE_FILES_FILTER);
-                    for (File f : files) {
-                        if (f.isDirectory()) {
-                            FileUtils.deleteDirectory(f);
-                        } else{
-                            if (!f.delete()) {
-                                LOG.warn("Could not delete {}", f);
+                    if (files != null) {
+                        for (File f : files) {
+                            if (f.isDirectory()) {
+                                FileUtils.deleteDirectory(f);
+                            } else{
+                                if (!f.delete()) {
+                                    LOG.warn("Could not delete {}", f);
+                                }
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
index e5ee8d7..36b7349 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
@@ -376,8 +376,9 @@ public class GarbageCollectorThread extends BookieThread {
      */
     private void doGcEntryLogs() {
         // Loop through all of the entry logs and remove the non-active ledgers.
-        for (Long entryLogId : entryLogMetaMap.keySet()) {
-            EntryLogMetadata meta = entryLogMetaMap.get(entryLogId);
+        for (Map.Entry<Long,EntryLogMetadata> entry :  entryLogMetaMap.entrySet())
{
+            long entryLogId = entry.getKey();
+            EntryLogMetadata meta = entry.getValue();
             for (Long entryLogLedger : meta.getLedgersMap().keySet()) {
                 // Remove the entry log ledger from the set if it isn't active.
                 try {

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/IndexPersistenceMgr.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/IndexPersistenceMgr.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/IndexPersistenceMgr.java
index 573ad45..8988985 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/IndexPersistenceMgr.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/IndexPersistenceMgr.java
@@ -189,11 +189,23 @@ public class IndexPersistenceMgr {
         // grandParent directory. We'll have to go two levels deep into these
         // directories to find the index files.
         for (File ledgerDirectory : ledgerDirsManager.getAllLedgerDirs()) {
-            for (File grandParent : ledgerDirectory.listFiles()) {
+            File[] grandParents = ledgerDirectory.listFiles();
+            if (grandParents == null) {
+                continue;
+            }
+            for (File grandParent : grandParents) {
                 if (grandParent.isDirectory()) {
-                    for (File parent : grandParent.listFiles()) {
+                    File[] parents = grandParent.listFiles();
+                    if (parents == null) {
+                        continue;
+                    }
+                    for (File parent : parents) {
                         if (parent.isDirectory()) {
-                            for (File index : parent.listFiles()) {
+                            File[] indexFiles = parent.listFiles();
+                            if (indexFiles == null) {
+                                continue;
+                            }
+                            for (File index : indexFiles) {
                                 if (!index.isFile()
                                         || (!index.getName().endsWith(IDX) && !index.getName().endsWith(RLOC)))
{
                                     continue;

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
index 08394c1..eaf66d9 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
@@ -75,6 +75,9 @@ class Journal extends BookieCriticalThread implements CheckpointSource {
      */
     private static List<Long> listJournalIds(File journalDir, JournalIdFilter filter)
{
         File logFiles[] = journalDir.listFiles();
+        if (logFiles == null || logFiles.length == 0) {
+            return Collections.emptyList();
+        }
         List<Long> logs = new ArrayList<Long>();
         for(File f: logFiles) {
             String name = f.getName();

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
index 0bc5c45..1ad17fd 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
@@ -406,6 +406,9 @@ public class BookKeeperAdmin {
 
         @Override
         public LedgerEntry next() {
+            if (lastEntryId > -1 && nextEntryId > lastEntryId) {
+                throw new NoSuchElementException();
+            }
             ++nextEntryId;
             LedgerEntry entry = currentEntry;
             currentEntry = null;

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
----------------------------------------------------------------------
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 cfe3e50..f539186 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
@@ -298,8 +298,8 @@ public class LedgerMetadata {
 
         if (customMetadata != null) {
             LedgerMetadataFormat.cMetadataMapEntry.Builder cMetadataBuilder = LedgerMetadataFormat.cMetadataMapEntry.newBuilder();
-            for (String key : customMetadata.keySet()) {
-                cMetadataBuilder.setKey(key).setValue(ByteString.copyFrom(customMetadata.get(key)));
+            for (Map.Entry<String,byte[]> entry : customMetadata.entrySet()) {
+                cMetadataBuilder.setKey(entry.getKey()).setValue(ByteString.copyFrom(entry.getValue()));
                 builder.addCustomMetadata(cMetadataBuilder.build());
             }
         }
@@ -371,7 +371,7 @@ public class LedgerMetadata {
         }
         if (versionLine.startsWith(VERSION_KEY)) {
             String parts[] = versionLine.split(tSplitter);
-            lc.metadataFormatVersion = new Integer(parts[1]);
+            lc.metadataFormatVersion = Integer.parseInt(parts[1]);
         } else {
             // if no version is set, take it to be version 1
             // as the parsing is the same as what we had before
@@ -440,16 +440,16 @@ public class LedgerMetadata {
     static LedgerMetadata parseVersion1Config(LedgerMetadata lc,
                                               BufferedReader reader) throws IOException {
         try {
-            lc.writeQuorumSize = lc.ackQuorumSize = new Integer(reader.readLine());
-            lc.ensembleSize = new Integer(reader.readLine());
-            lc.length = new Long(reader.readLine());
+            lc.writeQuorumSize = lc.ackQuorumSize = Integer.parseInt(reader.readLine());
+            lc.ensembleSize = Integer.parseInt(reader.readLine());
+            lc.length = Long.parseLong(reader.readLine());
 
             String line = reader.readLine();
             while (line != null) {
                 String parts[] = line.split(tSplitter);
 
                 if (parts[1].equals(closed)) {
-                    Long l = new Long(parts[0]);
+                    Long l = Long.parseLong(parts[0]);
                     if (l == IN_RECOVERY) {
                         lc.state = LedgerMetadataFormat.State.IN_RECOVERY;
                     } else {
@@ -465,7 +465,7 @@ public class LedgerMetadata {
                 for (int j = 1; j < parts.length; j++) {
                     addrs.add(new BookieSocketAddress(parts[j]));
                 }
-                lc.addEnsemble(new Long(parts[0]), addrs);
+                lc.addEnsemble(Long.parseLong(parts[0]), addrs);
                 line = reader.readLine();
             }
         } catch (NumberFormatException e) {

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
index d358ffb..313f1c1 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
@@ -190,7 +190,7 @@ class LedgerLayout {
         String lines[] = layout.split(lSplitter);
 
         try {
-            int layoutFormatVersion = new Integer(lines[0]);
+            int layoutFormatVersion = Integer.parseInt(lines[0]);
             if (LAYOUT_FORMAT_VERSION < layoutFormatVersion ||
                 LAYOUT_MIN_COMPAT_VERSION > layoutFormatVersion) {
                 throw new IOException("Metadata version not compatible. Expected " 
@@ -208,7 +208,7 @@ class LedgerLayout {
             // ledger manager factory class
             String managerFactoryCls = parts[0];
             // ledger manager version
-            int managerVersion = new Integer(parts[1]);
+            int managerVersion = Integer.parseInt(parts[1]);
             return new LedgerLayout(managerFactoryCls, managerVersion, layoutFormatVersion);
         } catch (NumberFormatException e) {
             throw new IOException("Could not parse layout '" + layout + "'", e);

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
index 363b517..e307b2c 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
@@ -196,7 +196,7 @@ public class ZkLedgerUnderreplicationManager implements LedgerUnderreplicationMa
     private long getLedgerId(String path) throws NumberFormatException {
         Matcher m = idExtractionPattern.matcher(path);
         if (m.find()) {
-            return Long.valueOf(m.group(1));
+            return Long.parseLong(m.group(1));
         } else {
             throw new NumberFormatException("Couldn't find ledgerid in path");
         }

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/MetastoreTable.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/MetastoreTable.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/MetastoreTable.java
index 735931e..cfc728b 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/MetastoreTable.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/MetastoreTable.java
@@ -17,7 +17,7 @@
  */
 package org.apache.bookkeeper.metastore;
 
-import java.util.HashSet;
+import java.util.Collections;
 import java.util.Set;
 import org.apache.bookkeeper.versioning.Version;
 import org.apache.bookkeeper.versioning.Versioned;
@@ -27,7 +27,7 @@ public interface MetastoreTable {
     // select all fields when reading or scanning entries
     public static final Set<String> ALL_FIELDS = null;
     // select non fields to return when reading/scanning entries
-    public static final Set<String> NON_FIELDS = new HashSet<String>();
+    public static final Set<String> NON_FIELDS = Collections.emptySet();
 
     /**
      * Get table name.

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java
index 9424bf9..ef89245 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java
@@ -106,8 +106,9 @@ public class Value {
         if (fields.size() != other.fields.size()) {
             return false;
         }
-        for (String f : fields.keySet()) {
-            byte[] v1 = fields.get(f);
+        for (Map.Entry<String,byte[]> entry : fields.entrySet()) {
+            String f = entry.getKey();
+            byte[] v1 = entry.getValue();
             byte[] v2 = other.fields.get(f);
             if (0 != comparator.compare(v1, v2)) {
                 return false;

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/2f71beb5/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
index c4fb77d..6d8f8f1 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
@@ -325,7 +325,7 @@ public class AuditorElector {
         AuditorVoteFormat v = builder.build();
         String[] parts = v.getBookieId().split(":");
         return new BookieSocketAddress(parts[0],
-                                       Integer.valueOf(parts[1]));
+                                       Integer.parseInt(parts[1]));
     }
 
     /**


Mime
View raw message