Repository: hbase
Updated Branches:
  refs/heads/branch-2 74c6f4487 -> cfa1bd326


HBASE-18180 Possible connection leak while closing BufferedMutator in 
TableOutputFormat

Signed-off-by: tedyu <yuzhih...@gmail.com>


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

Branch: refs/heads/branch-2
Commit: cfa1bd3265f5a564131e9cd075fc70e95aa2fd1b
Parents: 74c6f44
Author: Pankaj Kumar <pankaj...@huawei.com>
Authored: Mon Jun 12 19:51:41 2017 +0800
Committer: tedyu <yuzhih...@gmail.com>
Committed: Mon Jun 19 02:02:54 2017 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/mapred/TableOutputFormat.java | 13 ++++++++-----
 .../hadoop/hbase/mapreduce/TableOutputFormat.java     | 14 ++++++++++----
 2 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/cfa1bd32/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
index eb4b66f..8878eee 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java
@@ -84,11 +84,14 @@ public class TableOutputFormat extends 
FileOutputFormat<ImmutableBytesWritable,
     }
 
     public void close(Reporter reporter) throws IOException {
-      if (this.m_mutator != null) {
-        this.m_mutator.close();
-      }
-      if (conn != null) {
-        this.conn.close();
+      try {
+        if (this.m_mutator != null) {
+          this.m_mutator.close();
+        }
+      } finally {
+        if (conn != null) {
+          this.conn.close();
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/cfa1bd32/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.java
index 615999f..5986df8 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.java
@@ -115,10 +115,16 @@ implements Configurable {
      * @see RecordWriter#close(TaskAttemptContext)
      */
     @Override
-    public void close(TaskAttemptContext context)
-    throws IOException {
-      mutator.close();
-      connection.close();
+    public void close(TaskAttemptContext context) throws IOException {
+      try {
+        if (mutator != null) {
+          mutator.close();
+        }
+      } finally {
+        if (connection != null) {
+          connection.close();
+        }
+      }
     }
 
     /**

Reply via email to