HBASE-19809 Fix findbugs and error-prone warnings in hbase-procedure (branch-2)


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

Branch: refs/heads/HBASE-19064
Commit: c269e63a07360eeee6db57e65b06f3df12b91373
Parents: 7224546
Author: Peter Somogyi <psomo...@cloudera.com>
Authored: Wed Jan 17 09:47:59 2018 +0100
Committer: Michael Stack <st...@apache.org>
Committed: Wed Jan 17 11:23:38 2018 -0800

----------------------------------------------------------------------
 .../hbase/procedure2/RemoteProcedureDispatcher.java       |  3 +++
 .../procedure2/store/wal/ProcedureWALPrettyPrinter.java   |  1 +
 .../org/apache/hadoop/hbase/procedure2/util/ByteSlot.java |  2 ++
 .../hadoop/hbase/procedure2/TestProcedureEvents.java      |  2 +-
 .../hadoop/hbase/procedure2/TestProcedureExecutor.java    |  2 +-
 .../hbase/procedure2/TestProcedureInMemoryChore.java      | 10 +++++-----
 .../hadoop/hbase/procedure2/TestProcedureReplayOrder.java |  5 +++--
 .../hbase/procedure2/TestStateMachineProcedure.java       |  8 +++++++-
 .../hadoop/hbase/procedure2/TestYieldProcedures.java      |  2 +-
 .../wal/ProcedureWALLoaderPerformanceEvaluation.java      |  5 ++---
 .../store/wal/ProcedureWALPerformanceEvaluation.java      |  2 +-
 11 files changed, 27 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java
 
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java
index bdff1ca..9da7748 100644
--- 
a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java
+++ 
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java
@@ -347,10 +347,12 @@ public abstract class RemoteProcedureDispatcher<TEnv, 
TRemote extends Comparable
       super(key, 0);
     }
 
+    @Override
     public TRemote getKey() {
       return getObject();
     }
 
+    @Override
     public synchronized void add(final RemoteProcedure operation) {
       if (this.operations == null) {
         this.operations = new HashSet<>();
@@ -364,6 +366,7 @@ public abstract class RemoteProcedureDispatcher<TEnv, 
TRemote extends Comparable
       }
     }
 
+    @Override
     public synchronized void dispatch() {
       if (operations != null) {
         remoteDispatch(getKey(), operations);

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPrettyPrinter.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPrettyPrinter.java
 
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPrettyPrinter.java
index eb8994b..3f007c6 100644
--- 
a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPrettyPrinter.java
+++ 
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPrettyPrinter.java
@@ -149,6 +149,7 @@ public class ProcedureWALPrettyPrinter extends Configured 
implements Tool {
    * @throws IOException
    *           Thrown upon file system errors etc.
    */
+  @Override
   public int run(final String[] args) throws IOException {
     // create options
     Options options = new Options();

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/util/ByteSlot.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/util/ByteSlot.java
 
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/util/ByteSlot.java
index 068a823..3e95de5 100644
--- 
a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/util/ByteSlot.java
+++ 
b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/util/ByteSlot.java
@@ -81,11 +81,13 @@ public class ByteSlot extends OutputStream {
     buf[offset] = (byte)b;
   }
 
+  @Override
   public void write(int b) {
     ensureCapacity(size + 1);
     buf[size++] = (byte)b;
   }
 
+  @Override
   public void write(byte[] b, int off, int len) {
     ensureCapacity(size + len);
     System.arraycopy(b, off, buf, size, len);

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureEvents.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureEvents.java
 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureEvents.java
index a0afe70..f36da82 100644
--- 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureEvents.java
+++ 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureEvents.java
@@ -160,7 +160,7 @@ public class TestProcedureEvents {
     }
 
     @Override
-    protected boolean setTimeoutFailure(final TestProcEnv env) {
+    protected synchronized boolean setTimeoutFailure(final TestProcEnv env) {
       int n = ntimeouts.incrementAndGet();
       LOG.info("HANDLE TIMEOUT " + this + " ntimeouts=" + n);
       setState(ProcedureState.RUNNABLE);

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureExecutor.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureExecutor.java
 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureExecutor.java
index 29a0472..e5b5070 100644
--- 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureExecutor.java
+++ 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureExecutor.java
@@ -186,5 +186,5 @@ public class TestProcedureExecutor {
     }
   }
 
-  private class TestProcEnv { }
+  private static class TestProcEnv { }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureInMemoryChore.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureInMemoryChore.java
 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureInMemoryChore.java
index 6546ea3..33d93d5 100644
--- 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureInMemoryChore.java
+++ 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureInMemoryChore.java
@@ -18,14 +18,17 @@
 
 package org.apache.hadoop.hbase.procedure2;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
 import org.apache.hadoop.hbase.procedure2.store.NoopProcedureStore;
-import org.apache.hadoop.hbase.testclassification.SmallTests;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -33,10 +36,6 @@ import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 @Category({MasterTests.class, SmallTests.class})
 public class TestProcedureInMemoryChore {
   private static final Logger LOG = 
LoggerFactory.getLogger(TestProcedureInMemoryChore.class);
@@ -49,6 +48,7 @@ public class TestProcedureInMemoryChore {
 
   private HBaseCommonTestingUtility htu;
 
+  @SuppressWarnings("rawtypes")
   @Before
   public void setUp() throws IOException {
     htu = new HBaseCommonTestingUtility();

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureReplayOrder.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureReplayOrder.java
 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureReplayOrder.java
index dc359a1..821901c 100644
--- 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureReplayOrder.java
+++ 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestProcedureReplayOrder.java
@@ -132,8 +132,9 @@ public class TestProcedureReplayOrder {
         public void run() {
           for (int i = 0; i < nprocPerThread; ++i) {
             try {
-              procExecutor.submitProcedure((Procedure)procClazz.newInstance());
-            } catch (InstantiationException|IllegalAccessException e) {
+              procExecutor.submitProcedure((Procedure)
+                procClazz.getDeclaredConstructor().newInstance());
+            } catch (Exception e) {
               LOG.error("unable to instantiate the procedure", e);
               fail("failure during the proc.newInstance(): " + e.getMessage());
             }

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.java
 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.java
index 43d47f2..563afbc 100644
--- 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.java
+++ 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.java
@@ -153,6 +153,7 @@ public class TestStateMachineProcedure {
 
   public static class TestSMProcedure
       extends StateMachineProcedure<TestProcEnv, TestSMProcedureState> {
+    @Override
     protected Flow executeFromState(TestProcEnv env, TestSMProcedureState 
state) {
       LOG.info("EXEC " + state + " " + this);
       env.execCount.incrementAndGet();
@@ -169,25 +170,30 @@ public class TestStateMachineProcedure {
       return Flow.HAS_MORE_STATE;
     }
 
+    @Override
     protected void rollbackState(TestProcEnv env, TestSMProcedureState state) {
       LOG.info("ROLLBACK " + state + " " + this);
       env.rollbackCount.incrementAndGet();
     }
 
+    @Override
     protected TestSMProcedureState getState(int stateId) {
       return TestSMProcedureState.values()[stateId];
     }
 
+    @Override
     protected int getStateId(TestSMProcedureState state) {
       return state.ordinal();
     }
 
+    @Override
     protected TestSMProcedureState getInitialState() {
       return TestSMProcedureState.STEP_1;
     }
   }
 
   public static class SimpleChildProcedure extends NoopProcedure<TestProcEnv> {
+    @Override
     protected Procedure[] execute(TestProcEnv env) {
       LOG.info("EXEC " + this);
       env.execCount.incrementAndGet();
@@ -204,7 +210,7 @@ public class TestStateMachineProcedure {
     }
   }
 
-  public class TestProcEnv {
+  public static class TestProcEnv {
     AtomicInteger execCount = new AtomicInteger(0);
     AtomicInteger rollbackCount = new AtomicInteger(0);
     boolean triggerChildRollback = false;

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java
 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java
index 2023535..e6fc4bb 100644
--- 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java
+++ 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java
@@ -186,7 +186,7 @@ public class TestYieldProcedures {
       extends StateMachineProcedure<TestProcEnv, 
TestStateMachineProcedure.State> {
     enum State { STATE_1, STATE_2, STATE_3 }
 
-    public class ExecutionInfo {
+    public static class ExecutionInfo {
       private final boolean rollback;
       private final long timestamp;
       private final State step;

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java
 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java
index 503850d..3c908fd 100644
--- 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java
+++ 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java
@@ -70,7 +70,7 @@ public class ProcedureWALLoaderPerformanceEvaluation extends 
AbstractHBaseTool {
   private WALProcedureStore store;
   static byte[] serializedState;
 
-  private class LoadCounter implements ProcedureStore.ProcedureLoader {
+  private static class LoadCounter implements ProcedureStore.ProcedureLoader {
     public LoadCounter() {}
 
     @Override
@@ -165,8 +165,7 @@ public class ProcedureWALLoaderPerformanceEvaluation 
extends AbstractHBaseTool {
   private void writeWals() throws IOException {
     List<Integer> procStates = shuffleProcWriteSequence();
     TestProcedure[] procs = new TestProcedure[numProcs + 1];  // 0 is not used.
-    int numProcsPerWal = numWals > 0 ? (int)Math.ceil(procStates.size() / 
numWals)
-        : Integer.MAX_VALUE;
+    int numProcsPerWal = numWals > 0 ? procStates.size() / numWals : 
Integer.MAX_VALUE;
     long startTime = currentTimeMillis();
     long lastTime = startTime;
     for (int i = 0; i < procStates.size(); ++i) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/c269e63a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java
----------------------------------------------------------------------
diff --git 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java
 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java
index 1a7fc80..12ed930 100644
--- 
a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java
+++ 
b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java
@@ -243,7 +243,7 @@ public class ProcedureWALPerformanceEvaluation extends 
AbstractHBaseTool {
     }
   }
 
-  private class NoSyncWalProcedureStore extends WALProcedureStore {
+  private static class NoSyncWalProcedureStore extends WALProcedureStore {
     public NoSyncWalProcedureStore(final Configuration conf, final Path 
logDir) throws IOException {
       super(conf, logDir, null, new WALProcedureStore.LeaseRecovery() {
         @Override

Reply via email to