PHOENIX-4041 CoprocessorHConnectionTableFactory should not open a new HConnection when shutting down
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/IndexWriterUtils.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/IndexWriterUtils.java
index ea4ec1a..a82b277 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/IndexWriterUtils.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/IndexWriterUtils.java
@@ -121,11 +121,13 @@
}
@Override
- public void shutdown() {
+ public synchronized void shutdown() {
try {
- getConnection(conf).close();
- } catch (IOException e) {
- LOG.error("Exception caught while trying to close the HConnection used by CoprocessorHConnectionTableFactory");
+ if (connection != null && !connection.isClosed()) {
+ connection.close();
+ }
+ } catch (Throwable e) {
+ LOG.warn("Error while trying to close the HConnection used by CoprocessorHConnectionTableFactory", e);
}
}