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 GitHub
parent b68229c479
commit 77a21b93c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
}
}
}