HBASE-18180 Possible connection leak while closing BufferedMutator in TableOutputFormat

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
Pankaj Kumar 2017-06-12 19:51:41 +08:00 committed by tedyu
parent 74c6f44877
commit cfa1bd3265
2 changed files with 18 additions and 9 deletions

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}
/**