HBASE-27426 - Fix ZKWatcher shutdown seqence to avoid InterruptExcept… (#4829)

Signed-off-by: Andrew Purtell <apurtell@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
Co-authored-by: Victor Li <victor.li@salesforce.com>
This commit is contained in:
Victor 2022-10-17 13:26:09 -07:00 committed by Andrew Purtell
parent 511e0105ae
commit 6a40867804
1 changed files with 10 additions and 2 deletions

View File

@ -735,12 +735,20 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
*/
@Override
public void close() {
zkEventProcessor.shutdown();
try {
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 {
try {
recoverableZooKeeper.close();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
zkEventProcessor.shutdownNow();
}
}
}