hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [1/2] hbase git commit: HBASE-15118 Fix findbugs complaint in hbase-server
Date Mon, 18 Jan 2016 21:58:27 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 47fc696bc -> 9bf26f46d


http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/RegionReplicaReplicationEndpoint.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/RegionReplicaReplicationEndpoint.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/RegionReplicaReplicationEndpoint.java
index 30153f8..de87ac3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/RegionReplicaReplicationEndpoint.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/RegionReplicaReplicationEndpoint.java
@@ -115,7 +115,7 @@ public class RegionReplicaReplicationEndpoint extends HBaseReplicationEndpoint
{
    * Skips the entries which has original seqId. Only entries persisted via distributed log
replay
    * have their original seq Id fields set.
    */
-  private class SkipReplayedEditsFilter extends BaseWALEntryFilter {
+  private static class SkipReplayedEditsFilter extends BaseWALEntryFilter {
     @Override
     public Entry filter(Entry entry) {
       // if orig seq id is set, skip replaying the entry

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java
index 3541ade..06a2298 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/SecureBulkLoadEndpoint.java
@@ -280,7 +280,6 @@ public class SecureBulkLoadEndpoint extends SecureBulkLoadService
             Configuration conf = env.getConfiguration();
             fs = FileSystem.get(conf);
             for(Pair<byte[], String> el: familyPaths) {
-              Path p = new Path(el.getSecond());
               Path stageFamily = new Path(bulkToken, Bytes.toString(el.getFirst()));
               if(!fs.exists(stageFamily)) {
                 fs.mkdirs(stageFamily);

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/TableAuthManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/TableAuthManager.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/TableAuthManager.java
index e98f7a5..f7479cf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/TableAuthManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/TableAuthManager.java
@@ -338,12 +338,6 @@ public class TableAuthManager implements Closeable {
 
   private boolean authorize(List<TablePermission> perms,
                             TableName table, byte[] family,
-                            Permission.Action action) {
-    return authorize(perms, table, family, null, action);
-  }
-
-  private boolean authorize(List<TablePermission> perms,
-                            TableName table, byte[] family,
                             byte[] qualifier, Permission.Action action) {
     if (perms != null) {
       for (TablePermission p : perms) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/AuthenticationTokenSecretManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/AuthenticationTokenSecretManager.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/AuthenticationTokenSecretManager.java
index 1f2bec4..72f4598 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/AuthenticationTokenSecretManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/AuthenticationTokenSecretManager.java
@@ -124,7 +124,7 @@ public class AuthenticationTokenSecretManager
   }
 
   @Override
-  protected byte[] createPassword(AuthenticationTokenIdentifier identifier) {
+  protected synchronized byte[] createPassword(AuthenticationTokenIdentifier identifier)
{
     long now = EnvironmentEdgeManager.currentTime();
     AuthenticationKey secretKey = currentKey;
     identifier.setKeyId(secretKey.getKeyId());
@@ -229,7 +229,7 @@ public class AuthenticationTokenSecretManager
     return true;
   }
 
-  AuthenticationKey getCurrentKey() {
+  synchronized AuthenticationKey getCurrentKey() {
     return currentKey;
   }
 
@@ -338,8 +338,11 @@ public class AuthenticationTokenSecretManager
 
         // clear any expired
         removeExpiredKeys();
-
-        if (lastKeyUpdate + keyUpdateInterval < now) {
+        long localLastKeyUpdate;
+        synchronized (this) {
+          localLastKeyUpdate = lastKeyUpdate;
+        }
+        if (localLastKeyUpdate + keyUpdateInterval < now) {
           // roll a new master key
           rollCurrentKey();
         }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
index b025758..347f3da 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
@@ -274,8 +274,10 @@ public class VisibilityController extends BaseMasterAndRegionObserver
implements
     // Read the entire labels table and populate the zk
     if (e.getEnvironment().getRegion().getRegionInfo().getTable().equals(LABELS_TABLE_NAME))
{
       this.labelsRegion = true;
-      this.accessControllerAvailable = CoprocessorHost.getLoadedCoprocessors()
+      synchronized (this) {
+        this.accessControllerAvailable = CoprocessorHost.getLoadedCoprocessors()
           .contains(AccessController.class.getName());
+      }
       // Defer the init of VisibilityLabelService on labels region until it is in recovering
state.
       if (!e.getEnvironment().getRegion().isRecovering()) {
         initVisibilityLabelService(e.getEnvironment());

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
index c0b2ce8..d17e36b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
@@ -643,7 +643,6 @@ public class ExportSnapshot extends Configured implements Tool {
     @Override
     public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException
{
       Configuration conf = context.getConfiguration();
-      String snapshotName = conf.get(CONF_SNAPSHOT_NAME);
       Path snapshotDir = new Path(conf.get(CONF_SNAPSHOT_DIR));
       FileSystem fs = FileSystem.get(snapshotDir.toUri(), conf);
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java
index c5db43e..95803f5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java
@@ -280,6 +280,8 @@ public final class SnapshotInfo extends Configured implements Tool {
   private SnapshotManifest snapshotManifest;
 
   @Override
+  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION",
+    justification="Intentional")
   public int run(String[] args) throws IOException, InterruptedException {
     final Configuration conf = getConf();
     boolean listSnapshots = false;
@@ -317,7 +319,7 @@ public final class SnapshotInfo extends Configured implements Tool {
           printUsageAndExit();
         }
       } catch (Exception e) {
-        printUsageAndExit();
+        printUsageAndExit(); // FindBugs: REC_CATCH_EXCEPTION
       }
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index 9dbeed7..c066803 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -3564,9 +3564,8 @@ public class HBaseFsck extends Configured implements Closeable {
       this.metaEntry = metaEntry;
     }
 
-    public int getReplicaId() {
-      if (metaEntry != null) return metaEntry.getReplicaId();
-      return deployedReplicaId;
+    public synchronized int getReplicaId() {
+      return metaEntry != null? metaEntry.getReplicaId(): deployedReplicaId;
     }
 
     public synchronized void addServer(HRegionInfo hri, ServerName server) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/util/IdReadWriteLock.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/IdReadWriteLock.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/IdReadWriteLock.java
index 7dc6fbf..98ce80d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/IdReadWriteLock.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/IdReadWriteLock.java
@@ -68,12 +68,17 @@ public class IdReadWriteLock {
   /** For testing */
   @VisibleForTesting
   int purgeAndGetEntryPoolSize() {
-    System.gc();
+    gc();
     Threads.sleep(200);
     lockPool.purge();
     return lockPool.size();
   }
 
+  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DM_GC", justification="Intentional")
+  private void gc() {
+    System.gc();
+  }
+
   @VisibleForTesting
   public void waitForWaiters(long id, int numWaiters) throws InterruptedException {
     for (ReentrantReadWriteLock readWriteLock;;) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java
index 309bd4a..7c89f11 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java
@@ -104,11 +104,8 @@ public class MetaUtils {
    * @return HRegion for meta region
    * @throws IOException e
    */
-  public HRegion getMetaRegion() throws IOException {
-    if (this.metaRegion == null) {
-      openMetaRegion();
-    }
-    return this.metaRegion;
+  public synchronized HRegion getMetaRegion() throws IOException {
+    return this.metaRegion == null? openMetaRegion(): this.metaRegion;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionMover.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionMover.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionMover.java
index ea7034a..f661e0d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionMover.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionMover.java
@@ -455,9 +455,11 @@ public class RegionMover extends AbstractHBaseTool {
     }
   }
 
+  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DLS_DEAD_LOCAL_STORE",
+      justification="FB is wrong; its size is read")
   private void unloadRegions(Admin admin, String server, ArrayList<String> regionServers,
       boolean ack, List<HRegionInfo> movedRegions) throws Exception {
-    List<HRegionInfo> regionsToMove = new ArrayList<HRegionInfo>();
+    List<HRegionInfo> regionsToMove = new ArrayList<HRegionInfo>();// FindBugs:
DLS_DEAD_LOCAL_STORE
     regionsToMove = getRegions(this.conf, server);
     if (regionsToMove.size() == 0) {
       LOG.info("No Regions to move....Quitting now");
@@ -597,7 +599,7 @@ public class RegionMover extends AbstractHBaseTool {
    * Move Regions without Acknowledging.Usefule in case of RS shutdown as we might want to
shut the
    * RS down anyways and not abort on a stuck region. Improves movement performance
    */
-  private class MoveWithoutAck implements Callable<Boolean> {
+  private static class MoveWithoutAck implements Callable<Boolean> {
     private Admin admin;
     private HRegionInfo region;
     private String targetServer;
@@ -764,7 +766,7 @@ public class RegionMover extends AbstractHBaseTool {
       try {
         br = new BufferedReader(new FileReader(f));
         while ((line = br.readLine()) != null) {
-          line.trim();
+          line = line.trim();
           if (!line.equals("")) {
             excludeServers.add(line);
           }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/main/java/org/apache/hadoop/hbase/util/SortedList.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/SortedList.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/SortedList.java
index 75d77ed..39f1f41 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/SortedList.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/SortedList.java
@@ -46,6 +46,8 @@ import java.util.RandomAccess;
  * <p>
  * Iterators are read-only. They cannot be used to remove elements.
  */
+@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="UG_SYNC_SET_UNSYNC_GET",
+  justification="TODO: synchronization in here needs review!!!")
 public class SortedList<E> implements List<E>, RandomAccess {
   private volatile List<E> list;
   private final Comparator<? super E> comparator;
@@ -80,7 +82,7 @@ public class SortedList<E> implements List<E>, RandomAccess
{
    * method to get a reference for iterating over using the RandomAccess
    * pattern.
    */
-  public List<E> get() {
+  public List<E> get() { // FindBugs: UG_SYNC_SET_UNSYNC_GET complaint. Fix!!
     return list;
   }
 
@@ -185,7 +187,7 @@ public class SortedList<E> implements List<E>, RandomAccess
{
   }
 
   @Override
-  public E get(int index) {
+  public synchronized E get(int index) {
     return list.get(index);
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/9bf26f46/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
index c7707b7..d0dbb0d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
@@ -345,7 +345,7 @@ public class TestSplitLogManager {
     assertTrue(task == task2);
     LOG.debug("task = " + task);
     assertEquals(1L, tot_mgr_resubmit.get());
-    assertEquals(1, task.incarnation);
+    assertEquals(1, task.incarnation.get());
     assertEquals(0, task.unforcedResubmits.get());
     assertTrue(task.isOrphan());
     assertTrue(task.isUnassigned());


Mime
View raw message