HBASE-18180 Possible connection leak while closing BufferedMutator in TableOutputFormat
Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
c6e71f159c
commit
ce1ce728c6
|
@ -84,13 +84,16 @@ public class TableOutputFormat extends FileOutputFormat<ImmutableBytesWritable,
|
|||
}
|
||||
|
||||
public void close(Reporter reporter) throws IOException {
|
||||
try {
|
||||
if (this.m_mutator != null) {
|
||||
this.m_mutator.close();
|
||||
}
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
this.conn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void write(ImmutableBytesWritable key, Put value) throws IOException {
|
||||
m_mutator.mutate(new Put(value));
|
||||
|
|
|
@ -115,11 +115,17 @@ implements Configurable {
|
|||
* @see RecordWriter#close(TaskAttemptContext)
|
||||
*/
|
||||
@Override
|
||||
public void close(TaskAttemptContext context)
|
||||
throws IOException {
|
||||
public void close(TaskAttemptContext context) throws IOException {
|
||||
try {
|
||||
if (mutator != null) {
|
||||
mutator.close();
|
||||
}
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a key/value pair into the table.
|
||||
|
|
Loading…
Reference in New Issue