diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java index 9608ffc17c6..f499d0f9487 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java @@ -735,12 +735,20 @@ public class ZKWatcher implements Watcher, Abortable, Closeable { */ @Override public void close() { + zkEventProcessor.shutdown(); try { - recoverableZooKeeper.close(); + if (!zkEventProcessor.awaitTermination(15, TimeUnit.SECONDS)) { + LOG.warn("ZKWatcher event processor has not finished to terminate."); + zkEventProcessor.shutdownNow(); + } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { - zkEventProcessor.shutdownNow(); + try { + recoverableZooKeeper.close(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } } }