hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nkey...@apache.org
Subject svn commit: r1522852 - /hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
Date Fri, 13 Sep 2013 10:35:13 GMT
Author: nkeywal
Date: Fri Sep 13 10:35:13 2013
New Revision: 1522852

URL: http://svn.apache.org/r1522852
Log:
HBASE-9486 NPE in HTable.close() with AsyncProcess

Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java?rev=1522852&r1=1522851&r2=1522852&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
(original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
Fri Sep 13 10:35:13 2013
@@ -145,23 +145,27 @@ class AsyncProcess<CResult> {
   }
 
   private static class BatchErrors {
-    private List<Throwable> throwables = new ArrayList<Throwable>();
-    private List<Row> actions = new ArrayList<Row>();
-    private List<String> addresses = new ArrayList<String>();
+    private final List<Throwable> throwables = new ArrayList<Throwable>();
+    private final List<Row> actions = new ArrayList<Row>();
+    private final List<String> addresses = new ArrayList<String>();
+
+    public synchronized void add(Throwable ex, Row row, HRegionLocation location) {
+      if (row == null){
+        throw new IllegalArgumentException("row cannot be null. location=" + location);
+      }
 
-    public void add(Throwable ex, Row row, HRegionLocation location) {
       throwables.add(ex);
       actions.add(row);
       addresses.add(location != null ? location.getHostnamePort() : "null location");
     }
 
-    private RetriesExhaustedWithDetailsException makeException() {
+    private synchronized RetriesExhaustedWithDetailsException makeException() {
       return new RetriesExhaustedWithDetailsException(
           new ArrayList<Throwable>(throwables),
           new ArrayList<Row>(actions), new ArrayList<String>(addresses));
     }
 
-    public void clear() {
+    public synchronized void clear() {
       throwables.clear();
       actions.clear();
       addresses.clear();
@@ -171,6 +175,10 @@ class AsyncProcess<CResult> {
   public AsyncProcess(HConnection hc, TableName tableName, ExecutorService pool,
       AsyncProcessCallback<CResult> callback, Configuration conf,
       RpcRetryingCallerFactory rpcCaller) {
+    if (hc == null){
+      throw new IllegalArgumentException("HConnection cannot be null.");
+    }
+
     this.hConnection = hc;
     this.tableName = tableName;
     this.pool = pool;
@@ -283,6 +291,10 @@ class AsyncProcess<CResult> {
   private HRegionLocation findDestLocation(Row row, int numAttempt,
                                            int posInList, boolean force,
                                            Map<String, Boolean> regionStatus) {
+    if (row == null){
+      throw new IllegalArgumentException("row cannot be null");
+    }
+
     HRegionLocation loc = null;
     IOException locationException = null;
     try {
@@ -608,10 +620,11 @@ class AsyncProcess<CResult> {
           ConnectionUtils.getPauseTime(pause, numAttempt));
       if (numAttempt > 3 && LOG.isDebugEnabled()) {
         // We use this value to have some logs when we have multiple failures, but not too
many
-        //  logs as errors are to be expected wehn region moves, split and so on
+        //  logs, as errors are to be expected when a region moves, splits and so on
         LOG.debug("Attempt #" + numAttempt + "/" + numTries + " failed " + failureCount +
-          " ops , resubmitting " + toReplay.size() + ", " + location + ", last exception
was: " +
-          throwable.getMessage() + ", sleeping " + backOffTime + "ms");
+            " ops , resubmitting " + toReplay.size() + ", " + location + ", last exception
was: " +
+            (throwable == null ? "null" : throwable.getMessage()) +
+            ", sleeping " + backOffTime + "ms");
       }
       try {
         Thread.sleep(backOffTime);



Mime
View raw message