hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chia7...@apache.org
Subject hbase git commit: HBASE-18315 Eliminate the findbugs warnings for hbase-rest
Date Tue, 08 Aug 2017 02:50:09 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 4279f0d2f -> 8b6cf0986


HBASE-18315 Eliminate the findbugs warnings for hbase-rest


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

Branch: refs/heads/branch-1
Commit: 8b6cf09869c62e56c943cab4d981a219515f0de4
Parents: 4279f0d
Author: Chia-Ping Tsai <chia7712@gmail.com>
Authored: Tue Aug 8 10:48:04 2017 +0800
Committer: Chia-Ping Tsai <chia7712@gmail.com>
Committed: Tue Aug 8 10:48:04 2017 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/rest/MultiRowResource.java     |  1 +
 .../apache/hadoop/hbase/rest/RESTServer.java    |  5 -----
 .../apache/hadoop/hbase/rest/RowResource.java   |  4 ++--
 .../org/apache/hadoop/hbase/rest/RowSpec.java   |  8 ++++----
 .../apache/hadoop/hbase/rest/TableResource.java |  1 +
 .../hbase/rest/model/ColumnSchemaModel.java     | 20 ++++++++++----------
 .../rest/model/NamespacesInstanceModel.java     | 11 ++++++-----
 .../hadoop/hbase/rest/model/ScannerModel.java   |  2 +-
 .../rest/model/StorageClusterStatusModel.java   |  3 ++-
 .../hbase/rest/model/TableRegionModel.java      |  2 +-
 .../hbase/rest/model/TableSchemaModel.java      | 14 +++++++-------
 11 files changed, 35 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java
index 9cafe27..b82cd70 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/MultiRowResource.java
@@ -66,6 +66,7 @@ public class MultiRowResource extends ResourceBase implements Constants
{
     }
   }
 
+  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION")
   @GET
   @Produces({ MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF })
   public Response get(final @Context UriInfo uriInfo) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
index a5c78bf..d25af1e 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
@@ -19,11 +19,9 @@
 package org.apache.hadoop.hbase.rest;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.HelpFormatter;
@@ -113,9 +111,6 @@ public class RESTServer implements Constants {
     restCSRFEnabled = conf.getBoolean(REST_CSRF_ENABLED_KEY, REST_CSRF_ENABLED_DEFAULT);
     if (restCSRFEnabled) {
       String[] urls = { "/*" };
-      Set<String> restCsrfMethodsToIgnore = new HashSet<>();
-      restCsrfMethodsToIgnore.addAll(getTrimmedStringList(conf,
-        REST_CSRF_METHODS_TO_IGNORE_KEY, REST_CSRF_METHODS_TO_IGNORE_DEFAULT));
       Map<String, String> restCsrfParams = RestCsrfPreventionFilter
           .getFilterParams(conf, "hbase.rest-csrf.");
       HttpServer.defineFilter(context, "csrf", RestCsrfPreventionFilter.class.getName(),

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
index d93fd39..61cc795 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
@@ -76,7 +76,7 @@ public class RowResource extends ResourceBase {
     this.tableResource = tableResource;
     this.rowspec = new RowSpec(rowspec);
     if (versions != null) {
-      this.rowspec.setMaxVersions(Integer.valueOf(versions));
+      this.rowspec.setMaxVersions(Integer.parseInt(versions));
     }
     this.check = check;
   }
@@ -277,7 +277,7 @@ public class RowResource extends ResourceBase {
       }
       vals = headers.getRequestHeader("X-Timestamp");
       if (vals != null && !vals.isEmpty()) {
-        timestamp = Long.valueOf(vals.get(0));
+        timestamp = Long.parseLong(vals.get(0));
       }
       if (column == null) {
         servlet.getMetrics().incrementFailedPutRequests(1);

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
index b6c1ca8..cc51c85 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
@@ -164,7 +164,7 @@ public class RowSpec {
         i++;
       }
       try {
-        time0 = Long.valueOf(URLDecoder.decode(stamp.toString(),
+        time0 = Long.parseLong(URLDecoder.decode(stamp.toString(),
           HConstants.UTF8_ENCODING));
       } catch (NumberFormatException e) {
         throw new IllegalArgumentException(e);
@@ -177,7 +177,7 @@ public class RowSpec {
           i++;
         }
         try {
-          time1 = Long.valueOf(URLDecoder.decode(stamp.toString(),
+          time1 = Long.parseLong(URLDecoder.decode(stamp.toString(),
             HConstants.UTF8_ENCODING));
         } catch (NumberFormatException e) {
           throw new IllegalArgumentException(e);
@@ -245,7 +245,7 @@ public class RowSpec {
           }
           sb.append(c);
         }
-        maxVersions = Integer.valueOf(sb.toString());
+        maxVersions = Integer.parseInt(sb.toString());
       } break;
       case 'n': {
         StringBuilder sb = new StringBuilder();
@@ -257,7 +257,7 @@ public class RowSpec {
           }
           sb.append(c);
         }
-        maxValues = Integer.valueOf(sb.toString());
+        maxValues = Integer.parseInt(sb.toString());
       } break;
       default:
         throw new IllegalArgumentException("unknown parameter '" + c + "'");

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
index 3a83b50..126328f 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
@@ -119,6 +119,7 @@ public class TableResource extends ResourceBase {
     return new RowResource(this, suffixglobbingspec, versions, check);
   }
 
+  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION")
   @Path("{scanspec: .*[*]$}")
   public TableScanResource  getScanResource(
       final @Context UriInfo uriInfo,

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ColumnSchemaModel.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ColumnSchemaModel.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ColumnSchemaModel.java
index ba0eed8..5be62a3 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ColumnSchemaModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ColumnSchemaModel.java
@@ -137,8 +137,8 @@ public class ColumnSchemaModel implements Serializable {
    */
   public boolean __getBlockcache() {
     Object o = attrs.get(BLOCKCACHE);
-    return o != null ? 
-      Boolean.valueOf(o.toString()) : HColumnDescriptor.DEFAULT_BLOCKCACHE;
+    return o != null ?
+      Boolean.parseBoolean(o.toString()) : HColumnDescriptor.DEFAULT_BLOCKCACHE;
   }
 
   /**
@@ -146,8 +146,8 @@ public class ColumnSchemaModel implements Serializable {
    */
   public int __getBlocksize() {
     Object o = attrs.get(BLOCKSIZE);
-    return o != null ? 
-      Integer.valueOf(o.toString()) : HColumnDescriptor.DEFAULT_BLOCKSIZE;
+    return o != null ?
+      Integer.parseInt(o.toString()) : HColumnDescriptor.DEFAULT_BLOCKSIZE;
   }
 
   /**
@@ -171,8 +171,8 @@ public class ColumnSchemaModel implements Serializable {
    */
   public boolean __getInMemory() {
     Object o = attrs.get(IN_MEMORY);
-    return o != null ? 
-      Boolean.valueOf(o.toString()) : HColumnDescriptor.DEFAULT_IN_MEMORY;
+    return o != null ?
+      Boolean.parseBoolean(o.toString()) : HColumnDescriptor.DEFAULT_IN_MEMORY;
   }
 
   /**
@@ -180,8 +180,8 @@ public class ColumnSchemaModel implements Serializable {
    */
   public int __getTTL() {
     Object o = attrs.get(TTL);
-    return o != null ? 
-      Integer.valueOf(o.toString()) : HColumnDescriptor.DEFAULT_TTL;
+    return o != null ?
+      Integer.parseInt(o.toString()) : HColumnDescriptor.DEFAULT_TTL;
   }
 
   /**
@@ -189,8 +189,8 @@ public class ColumnSchemaModel implements Serializable {
    */
   public int __getVersions() {
     Object o = attrs.get(VERSIONS);
-    return o != null ? 
-      Integer.valueOf(o.toString()) : HColumnDescriptor.DEFAULT_VERSIONS;
+    return o != null ?
+      Integer.parseInt(o.toString()) : HColumnDescriptor.DEFAULT_VERSIONS;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/NamespacesInstanceModel.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/NamespacesInstanceModel.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/NamespacesInstanceModel.java
index b31ecf9..7f18917 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/NamespacesInstanceModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/NamespacesInstanceModel.java
@@ -129,11 +129,11 @@ public class NamespacesInstanceModel implements Serializable, ProtobufMessageHan
     sb.append(namespaceName);
     sb.append("\'");
     if(properties != null){
-      for(String key: properties.keySet()){
+      for (Map.Entry<String, String> entry : properties.entrySet()) {
         sb.append(", ");
-        sb.append(key);
+        sb.append(entry.getKey());
         sb.append(" => '");
-        sb.append(properties.get(key));
+        sb.append(entry.getValue());
         sb.append("\'");
       }
     }
@@ -145,10 +145,11 @@ public class NamespacesInstanceModel implements Serializable, ProtobufMessageHan
   public byte[] createProtobufOutput() {
     NamespaceProperties.Builder builder = NamespaceProperties.newBuilder();
     if(properties != null){
-      for(String key: properties.keySet()){
+      for (Map.Entry<String, String> entry : properties.entrySet()) {
+        String key = entry.getKey();
         NamespaceProperties.Property.Builder property = NamespaceProperties.Property.newBuilder();
         property.setKey(key);
-        property.setValue(properties.get(key));
+        property.setValue(entry.getValue());
         builder.addProps(property);
       }
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
index 27f6b45..7512d3e 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
@@ -414,7 +414,7 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable
{
         }
       } break;
       case PageFilter:
-        filter = new PageFilter(Long.valueOf(value));
+        filter = new PageFilter(Long.parseLong(value));
         break;
       case PrefixFilter:
         filter = new PrefixFilter(Base64.decode(value));

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
index 4827b6e..97d40e4 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
@@ -107,7 +107,8 @@ public class StorageClusterStatusModel
     /**
      * Represents a region hosted on a region server.
      */
-    public static class Region {
+    public static class Region implements Serializable {
+      private static final long serialVersionUID = -1326683840086398193L;
       private byte[] name;
       private int stores;
       private int storefiles;

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableRegionModel.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableRegionModel.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableRegionModel.java
index d9b2b65..89fe12c 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableRegionModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableRegionModel.java
@@ -142,7 +142,7 @@ public class TableRegionModel implements Serializable {
     this.startKey = Bytes.toBytes(split[1]);
     String tail = split[2];
     split = tail.split("\\.");
-    id = Long.valueOf(split[0]);
+    id = Long.parseLong(split[0]);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/8b6cf098/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java
index 52e40b8..1de0b49 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java
@@ -223,7 +223,7 @@ public class TableSchemaModel implements Serializable, ProtobufMessageHandler
{
    */
   public boolean __getIsMeta() {
     Object o = attrs.get(IS_META);
-    return o != null ? Boolean.valueOf(o.toString()) : false;
+    return o != null ? Boolean.parseBoolean(o.toString()) : false;
   }
 
   /**
@@ -231,7 +231,7 @@ public class TableSchemaModel implements Serializable, ProtobufMessageHandler
{
    */
   public boolean __getIsRoot() {
     Object o = attrs.get(IS_ROOT);
-    return o != null ? Boolean.valueOf(o.toString()) : false;
+    return o != null ? Boolean.parseBoolean(o.toString()) : false;
   }
 
   /**
@@ -239,8 +239,8 @@ public class TableSchemaModel implements Serializable, ProtobufMessageHandler
{
    */
   public boolean __getReadOnly() {
     Object o = attrs.get(READONLY);
-    return o != null ? 
-      Boolean.valueOf(o.toString()) : HTableDescriptor.DEFAULT_READONLY;
+    return o != null ?
+      Boolean.parseBoolean(o.toString()) : HTableDescriptor.DEFAULT_READONLY;
   }
 
   /**
@@ -288,11 +288,11 @@ public class TableSchemaModel implements Serializable, ProtobufMessageHandler
{
       }
       if (familyAttrs.containsKey(TTL)) {
         familyBuilder.setTtl(
-          Integer.valueOf(familyAttrs.get(TTL).toString()));
+          Integer.parseInt(familyAttrs.get(TTL).toString()));
       }
       if (familyAttrs.containsKey(VERSIONS)) {
         familyBuilder.setMaxVersions(
-          Integer.valueOf(familyAttrs.get(VERSIONS).toString()));
+          Integer.parseInt(familyAttrs.get(VERSIONS).toString()));
       }
       if (familyAttrs.containsKey(COMPRESSION)) {
         familyBuilder.setCompression(familyAttrs.get(COMPRESSION).toString());
@@ -301,7 +301,7 @@ public class TableSchemaModel implements Serializable, ProtobufMessageHandler
{
     }
     if (attrs.containsKey(READONLY)) {
       builder.setReadOnly(
-        Boolean.valueOf(attrs.get(READONLY).toString()));
+        Boolean.parseBoolean(attrs.get(READONLY).toString()));
     }
     return builder.build().toByteArray();
   }


Mime
View raw message