hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmhs...@apache.org
Subject svn commit: r1310125 - in /hbase/trunk: dev-support/ src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ src/main/java/org/apache/hadoop/hbase/client/ src/main/java/org/apache/hadoop/hbase/mapreduce/ src/main/java/org/apache/hadoop/hbase/regionse...
Date Thu, 05 Apr 2012 23:05:07 GMT
Author: jmhsieh
Date: Thu Apr  5 23:05:07 2012
New Revision: 1310125

URL: http://svn.apache.org/viewvc?rev=1310125&view=rev
Log:
HBASE-5644 [findbugs] Fix null pointer warnings (Uma Maheswara Rao G)

Modified:
    hbase/trunk/dev-support/findbugs-exclude.xml
    hbase/trunk/dev-support/test-patch.properties
    hbase/trunk/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaConfigured.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Merge.java

Modified: hbase/trunk/dev-support/findbugs-exclude.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/dev-support/findbugs-exclude.xml?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/dev-support/findbugs-exclude.xml (original)
+++ hbase/trunk/dev-support/findbugs-exclude.xml Thu Apr  5 23:05:07 2012
@@ -30,6 +30,22 @@
 
      <Match>
        <Package name="org.apache.hadoop.hbase.protobuf.generated"/>
-     </Match>  
+     </Match>
+
+     <Match>
+       <Class name="org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost" />
+       <Or>
+         <Method name="preExists" />
+         <Method name="preCheckAndPut" />
+         <Method name="preCheckAndDelete" />
+         <Method name="preScannerNext" />
+       </Or>
+       <Bug pattern="NP_BOOLEAN_RETURN_NULL" />
+     </Match>
+
+    <Match>
+       <Class name="org.apache.hadoop.hbase.regionserver.StoreFile$Writer" />
+       <Bug pattern="NP_NULL_PARAM_DEREF" />
+     </Match>
 
 </FindBugsFilter>

Modified: hbase/trunk/dev-support/test-patch.properties
URL: http://svn.apache.org/viewvc/hbase/trunk/dev-support/test-patch.properties?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/dev-support/test-patch.properties (original)
+++ hbase/trunk/dev-support/test-patch.properties Thu Apr  5 23:05:07 2012
@@ -19,5 +19,5 @@ MAVEN_OPTS="-Xmx3g"
 # Please update the per-module test-patch.properties if you update this file.
 
 OK_RELEASEAUDIT_WARNINGS=84
-OK_FINDBUGS_WARNINGS=601
+OK_FINDBUGS_WARNINGS=585
 OK_JAVADOC_WARNINGS=169

Modified: hbase/trunk/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon
(original)
+++ hbase/trunk/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon
Thu Apr  5 23:05:07 2012
@@ -44,12 +44,8 @@ org.apache.hadoop.hbase.HBaseConfigurati
 <%java>
   HServerInfo serverInfo = null;
   ServerName serverName = null;
-  try {
-    serverInfo = regionServer.getHServerInfo();
-    serverName = regionServer.getServerName();
-  } catch (IOException e) {
-    e.printStackTrace();
-  }
+  serverInfo = regionServer.getHServerInfo();
+  serverName = regionServer.getServerName();
   RegionServerMetrics metrics = regionServer.getMetrics();
   List<HRegionInfo> onlineRegions = regionServer.getOnlineRegions();
   int interval = regionServer.getConfiguration().getInt("hbase.regionserver.msginterval",
3000)/1000;

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java Thu Apr  5 23:05:07
2012
@@ -746,12 +746,13 @@ public class HTable implements HTableInt
   @Override
   public void delete(final Delete delete)
   throws IOException {
-    new ServerCallable<Boolean>(connection, tableName, delete.getRow(), operationTimeout)
{
-          public Boolean call() throws IOException {
-            server.delete(location.getRegionInfo().getRegionName(), delete);
-            return null; // FindBugs NP_BOOLEAN_RETURN_NULL
-          }
-        }.withRetries();
+    new ServerCallable<Void>(connection, tableName, delete.getRow(),
+        operationTimeout) {
+      public Void call() throws IOException {
+        server.delete(location.getRegionInfo().getRegionName(), delete);
+        return null;
+      }
+    }.withRetries();
   }
 
   /**
@@ -1038,13 +1039,14 @@ public class HTable implements HTableInt
   @Override
   public void unlockRow(final RowLock rl)
   throws IOException {
-    new ServerCallable<Boolean>(connection, tableName, rl.getRow(), operationTimeout)
{
-        public Boolean call() throws IOException {
-          server.unlockRow(location.getRegionInfo().getRegionName(),
-              rl.getLockId());
-          return null; // FindBugs NP_BOOLEAN_RETURN_NULL
-        }
-      }.withRetries();
+    new ServerCallable<Void>(connection, tableName, rl.getRow(),
+        operationTimeout) {
+      public Void call() throws IOException {
+        server.unlockRow(location.getRegionInfo().getRegionName(), rl
+            .getLockId());
+        return null;
+      }
+    }.withRetries();
   }
 
   /**

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCounter.java Thu Apr 
5 23:05:07 2012
@@ -23,27 +23,30 @@ import java.io.IOException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.filter.*;
+import org.apache.hadoop.hbase.filter.CompareFilter;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.filter.PrefixFilter;
+import org.apache.hadoop.hbase.filter.RegexStringComparator;
+import org.apache.hadoop.hbase.filter.RowFilter;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.Text;
 import org.apache.hadoop.mapreduce.Job;
-import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
-import org.apache.hadoop.util.GenericOptionsParser;
+import org.apache.hadoop.mapreduce.Reducer;
 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
 import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.mapreduce.lib.reduce.IntSumReducer;
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.mapreduce.Reducer;
-import org.apache.hadoop.io.Text;
+import org.apache.hadoop.util.GenericOptionsParser;
+
+import com.google.common.base.Preconditions;
 
 
 /**
@@ -102,17 +105,16 @@ public class CellCounter {
     public void map(ImmutableBytesWritable row, Result values,
                     Context context)
         throws IOException {
+      Preconditions.checkState(values != null,
+          "values passed to the map is null");
       String currentFamilyName = null;
       String currentQualifierName = null;
       String currentRowKey = null;
       Configuration config = context.getConfiguration();
       String separator = config.get("ReportSeparator",":");
-
       try {
-        if (values != null) {
-          context.getCounter(Counters.ROWS).increment(1);
-          context.write(new Text("Total ROWS"), new IntWritable(1));
-        }
+        context.getCounter(Counters.ROWS).increment(1);
+        context.write(new Text("Total ROWS"), new IntWritable(1));
 
         for (KeyValue value : values.list()) {
           currentRowKey = Bytes.toStringBinary(value.getRow());

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Thu Apr  5
23:05:07 2012
@@ -634,8 +634,9 @@ public class HRegion implements HeapSize
     // being split but we crashed in the middle of it all.
     SplitTransaction.cleanupAnySplitDetritus(this);
     FSUtils.deleteDirectory(this.fs, new Path(regiondir, MERGEDIR));
-
-    this.writestate.setReadOnly(this.htableDescriptor.isReadOnly());
+    if (this.htableDescriptor != null) {
+      this.writestate.setReadOnly(this.htableDescriptor.isReadOnly());
+    }
 
     this.writestate.flushRequested = false;
     this.writestate.compacting = 0;
@@ -4987,7 +4988,7 @@ public class HRegion implements HeapSize
       // detect the actual protocol class
       protocol  = protocolHandlerNames.get(protocolName);
       if (protocol == null) {
-        throw new HBaseRPC.UnknownProtocolException(protocol,
+        throw new HBaseRPC.UnknownProtocolException(null,
             "No matching handler for protocol "+protocolName+
             " in region "+Bytes.toStringBinary(getRegionName()));
       }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java Thu Apr
 5 23:05:07 2012
@@ -168,6 +168,12 @@ public class ShutdownHook {
           break;
         }
       }
+
+      if (cache == null) {
+        throw new RuntimeException(
+            "This should not happen. Could not find the cache class in FileSystem.");
+      }
+
       Field field = null;
       try {
         field = cache.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java Thu Apr  5 23:05:07
2012
@@ -494,10 +494,10 @@ public class Store extends SchemaConfigu
       reader.loadFileInfo();
 
       byte[] firstKey = reader.getFirstRowKey();
+      Preconditions.checkState(firstKey != null, "First key can not be null");
       byte[] lk = reader.getLastKey();
-      byte[] lastKey =
-          (lk == null) ? null :
-              KeyValue.createKeyValueFromKey(lk).getRow();
+      Preconditions.checkState(lk != null, "Last key can not be null");
+      byte[] lastKey =  KeyValue.createKeyValueFromKey(lk).getRow();
 
       LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
           " last=" + Bytes.toStringBinary(lastKey));

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java Thu Apr
 5 23:05:07 2012
@@ -1758,12 +1758,15 @@ public class StoreFile extends SchemaCon
     /**
      * FILE_SIZE = descending sort StoreFiles (largest --> smallest in size)
      */
-    static final Comparator<StoreFile> FILE_SIZE =
-      Ordering.natural().reverse().onResultOf(new Function<StoreFile, Long>() {
-        @Override
-        public Long apply(StoreFile sf) {
-          return sf.getReader().length();
-        }
-      });
+    static final Comparator<StoreFile> FILE_SIZE = Ordering.natural().reverse()
+        .onResultOf(new Function<StoreFile, Long>() {
+          @Override
+          public Long apply(StoreFile sf) {
+            if (sf == null) {
+              throw new IllegalArgumentException("StorFile can not be null");
+            }
+            return sf.getReader().length();
+          }
+        });
   }
 }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaConfigured.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaConfigured.java?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaConfigured.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaConfigured.java
Thu Apr  5 23:05:07 2012
@@ -157,8 +157,12 @@ public class SchemaConfigured implements
   public SchemaConfigured(Configuration conf, String tableName, String cfName)
   {
     this(conf);
-    this.tableName = tableName != null ? tableName.intern() : tableName;
-    this.cfName = cfName != null ? cfName.intern() : cfName;
+    if (tableName != null) {
+      this.tableName = tableName.intern();
+    }
+    if (cfName != null) {
+      this.cfName = cfName.intern();
+    }
   }
 
   public SchemaConfigured(SchemaAware that) {

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Merge.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Merge.java?rev=1310125&r1=1310124&r2=1310125&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Merge.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/Merge.java Thu Apr  5 23:05:07
2012
@@ -45,6 +45,8 @@ import org.apache.hadoop.util.GenericOpt
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
 
+import com.google.common.base.Preconditions;
+
 import java.io.IOException;
 import java.util.List;
 
@@ -152,12 +154,14 @@ public class Merge extends Configured im
     Get get = new Get(region1);
     get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
     List<KeyValue> cells1 =  rootRegion.get(get, null).list();
-    HRegionInfo info1 = Writables.getHRegionInfo((cells1 == null)? null: cells1.get(0).getValue());
+    Preconditions.checkState(cells1 != null, "First region cells can not be null");
+    HRegionInfo info1 = Writables.getHRegionInfo(cells1.get(0).getValue());
 
     get = new Get(region2);
     get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
     List<KeyValue> cells2 =  rootRegion.get(get, null).list();
-    HRegionInfo info2 = Writables.getHRegionInfo((cells2 == null)? null: cells2.get(0).getValue());
+    Preconditions.checkState(cells2 != null, "Second region cells can not be null");
+    HRegionInfo info2 = Writables.getHRegionInfo(cells2.get(0).getValue());
     HRegion merged = merge(HTableDescriptor.META_TABLEDESC, info1, rootRegion, info2, rootRegion);
     LOG.info("Adding " + merged.getRegionInfo() + " to " +
         rootRegion.getRegionInfo());
@@ -221,8 +225,9 @@ public class Merge extends Configured im
     Get get = new Get(region1);
     get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
     List<KeyValue> cells1 =  metaRegion1.get(get, null).list();
-    HRegionInfo info1 =
-      Writables.getHRegionInfo((cells1 == null)? null: cells1.get(0).getValue());
+    Preconditions.checkState(cells1 != null,
+        "First region cells can not be null");
+    HRegionInfo info1 = Writables.getHRegionInfo(cells1.get(0).getValue());
     if (info1 == null) {
       throw new NullPointerException("info1 is null using key " +
           Bytes.toStringBinary(region1) + " in " + meta1);
@@ -237,7 +242,9 @@ public class Merge extends Configured im
     get = new Get(region2);
     get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
     List<KeyValue> cells2 =  metaRegion2.get(get, null).list();
-    HRegionInfo info2 = Writables.getHRegionInfo((cells2 == null)? null: cells2.get(0).getValue());
+    Preconditions.checkState(cells2 != null,
+        "Second region cells can not be null");
+    HRegionInfo info2 = Writables.getHRegionInfo(cells2.get(0).getValue());
     if (info2 == null) {
       throw new NullPointerException("info2 is null using key " + meta2);
     }



Mime
View raw message