You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/02/20 19:41:21 UTC

[GitHub] sijie closed pull request #1189: Always reset interrupted state after catching InterruptedException

sijie closed pull request #1189: Always reset interrupted state after catching InterruptedException
URL: https://github.com/apache/bookkeeper/pull/1189
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
index a55ff0462..750984f4a 100644
--- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
+++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
@@ -121,7 +121,7 @@ private static void readLedger(ClientConfiguration conf, long ledgerId, byte[] p
                 Thread.sleep(1000);
             }
         } catch (InterruptedException ie) {
-            // ignore
+            Thread.currentThread().interrupt();
         } catch (Exception e) {
             LOG.error("Exception in reader", e);
         } finally {
diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
index d9de4ac04..d0f5ec7ca 100644
--- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
+++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
@@ -147,6 +147,7 @@ public void run() {
                         }
                     } catch (InterruptedException ie) {
                         LOG.info("Caught interrupted exception, going away");
+                        Thread.currentThread().interrupt();
                     }
                 }
             };
@@ -162,6 +163,7 @@ public void run() {
                     LOG.info("Time to send first batch: {}s {}ns ", time / 1000 / 1000 / 1000, time);
                 }
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 break;
             }
 
@@ -188,6 +190,7 @@ public void run() {
             }
         } catch (InterruptedException e) {
             LOG.error("Interrupted while waiting", e);
+            Thread.currentThread().interrupt();
         }
         synchronized (this) {
             duration = System.currentTimeMillis() - start;
@@ -198,7 +201,7 @@ public void run() {
         try {
             reporter.join();
         } catch (InterruptedException ie) {
-            // ignore
+            Thread.currentThread().interrupt();
         }
         LOG.info("Finished processing in ms: " + getDuration() + " tp = " + throughput);
     }
diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
index 49f98a7bd..cf8b780d7 100644
--- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
+++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
@@ -180,6 +180,7 @@ public void run() {
             LOG.error("I/O exception during benchmark", ioe);
         } catch (InterruptedException ie) {
             LOG.error("Benchmark interrupted", ie);
+            Thread.currentThread().interrupt();
         } finally {
             if (bkc != null) {
                 try {
@@ -188,6 +189,7 @@ public void run() {
                     LOG.error("Error closing bookkeeper client", bke);
                 } catch (InterruptedException ie) {
                     LOG.warn("Interrupted closing bookkeeper client", ie);
+                    Thread.currentThread().interrupt();
                 }
             }
         }
@@ -280,6 +282,7 @@ public Long call() {
                 LOG.error("Exception in worker thread", e);
                 return 0L;
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
                 LOG.error("Exception in worker thread", ie);
                 return 0L;
             }
diff --git a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedScheduler.java b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedScheduler.java
index efc9df8b6..76dd375e5 100644
--- a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedScheduler.java
+++ b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedScheduler.java
@@ -216,6 +216,7 @@ public void safeRun() {
                     }
                 }).get();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 throw new RuntimeException("Couldn't start thread " + i, e);
             } catch (ExecutionException e) {
                 throw new RuntimeException("Couldn't start thread " + i, e);
diff --git a/bookkeeper-http/vertx-http-server/src/main/java/org/apache/bookkeeper/http/vertx/VertxHttpServer.java b/bookkeeper-http/vertx-http-server/src/main/java/org/apache/bookkeeper/http/vertx/VertxHttpServer.java
index 635d24ccb..26c07e84b 100644
--- a/bookkeeper-http/vertx-http-server/src/main/java/org/apache/bookkeeper/http/vertx/VertxHttpServer.java
+++ b/bookkeeper-http/vertx-http-server/src/main/java/org/apache/bookkeeper/http/vertx/VertxHttpServer.java
@@ -84,7 +84,10 @@ public void start() throws Exception {
             } else {
                 LOG.error("Failed to start org.apache.bookkeeper.http server on port {}", port, asyncResult.cause());
             }
-        } catch (InterruptedException | ExecutionException e) {
+        } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
+            LOG.error("Failed to start org.apache.bookkeeper.http server on port {}", port, ie);
+        } catch (ExecutionException e) {
             LOG.error("Failed to start org.apache.bookkeeper.http server on port {}", port, e);
         }
         return false;
@@ -106,6 +109,7 @@ public void stopServer() {
         try {
             shutdownLatch.await();
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Interrupted while shutting down org.apache.bookkeeper.http server");
         }
     }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
index a3d124796..7b28cdd31 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
@@ -944,6 +944,7 @@ public void run() {
             }
             LOG.info("Journal thread(s) quit.");
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             LOG.warn("Interrupted on running journal thread : ", ie);
         }
         // if the journal thread quits due to shutting down, it is ok
@@ -1035,6 +1036,7 @@ synchronized int shutdown(int exitCode) {
                 registrationManager.close();
             }
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             LOG.error("Interrupted during shutting down bookie : ", ie);
         } catch (Exception e) {
             LOG.error("Got Exception while trying to shutdown Bookie", e);
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
index 112a602af..df72899af 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
@@ -620,6 +620,7 @@ BufferedLogChannel createNewLog() throws IOException {
                         } catch (CancellationException ce) {
                             throw new IOException("Task to allocate a new entry log is cancelled.", ce);
                         } catch (InterruptedException ie) {
+                            Thread.currentThread().interrupt();
                             throw new IOException("Intrrupted when waiting a new entry log to be allocated.", ie);
                         }
                     }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
index fc1c80c7c..146a83e24 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
@@ -493,6 +493,7 @@ public void run() {
                     LOG.error("I/O exception in ForceWrite thread", ioe);
                     running = false;
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     LOG.error("ForceWrite thread interrupted", e);
                     // close is idempotent
                     if (null != req) {
@@ -1078,6 +1079,7 @@ public void run() {
         } catch (IOException ioe) {
             LOG.error("I/O exception in Journal thread!", ioe);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             LOG.warn("Journal exits when shutting down", ie);
         } finally {
             // There could be packets queued for forceWrite on this logFile
@@ -1111,6 +1113,7 @@ public synchronized void shutdown() {
             this.join();
             LOG.info("Finished Shutting down Journal thread");
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             LOG.warn("Interrupted during shutting down journal : ", ie);
         }
     }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ScanAndCompareGarbageCollector.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ScanAndCompareGarbageCollector.java
index 60ed34d2b..5f22d07fe 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ScanAndCompareGarbageCollector.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ScanAndCompareGarbageCollector.java
@@ -205,6 +205,7 @@ public void gc(GarbageCleaner garbageCleaner) {
                 try {
                     zk.close();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     LOG.error("Error closing zk session", e);
                 }
                 zk = null;
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorage.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorage.java
index 59d2b1b97..b2e9e3d70 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorage.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorage.java
@@ -367,6 +367,7 @@ private void triggerFlushAndAddEntry(long ledgerId, long entryId, ByteBuf entry)
             }
 
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new IOException("Interrupted when adding entry " + ledgerId + "@" + entryId);
         } finally {
             writeCacheMutex.writeLock().unlock();
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
index a723884f5..dcface641 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
@@ -1510,7 +1510,10 @@ private boolean areEntriesOfLedgerStoredInTheBookie(long ledgerId, BookieSocketA
                 }
             }
             return false;
-        } catch (InterruptedException | ExecutionException e) {
+        } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
+            throw new RuntimeException(ie);
+        } catch (ExecutionException e) {
             if (e.getCause() != null
                     && e.getCause().getClass().equals(BKException.BKNoSuchLedgerExistsException.class)) {
                 LOG.debug("Ledger: {} has been deleted", ledgerId);
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java
index 7147d6c2c..7639703c1 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieInfoReader.java
@@ -432,6 +432,7 @@ public void getBookieInfoComplete(int rc, BookieInfo bInfo, Object ctx) {
         try {
             latch.await();
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Received InterruptedException ", e);
             throw e;
         }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java
index 6633d9c6b..237809a08 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java
@@ -239,6 +239,7 @@ public RegistrationClient initialize(ClientConfiguration conf,
                 zke.fillInStackTrace();
                 throw zke;
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 throw new BKInterruptedException();
             }
             this.ownZKHandle = true;
@@ -259,6 +260,7 @@ public void close() {
             try {
                 zk.close();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 log.warn("Interrupted on closing zookeeper client", e);
             }
         }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationManager.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationManager.java
index 66f25096a..c1079a9d2 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationManager.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationManager.java
@@ -131,7 +131,10 @@ public RegistrationManager initialize(ServerConfiguration conf,
 
         try {
             this.zk = newZookeeper(conf, listener);
-        } catch (InterruptedException | KeeperException | IOException e) {
+        } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
+            throw new MetadataStoreException(ie);
+        } catch (KeeperException | IOException e) {
             throw new MetadataStoreException(e);
         }
 
@@ -202,6 +205,7 @@ public void close() {
             try {
                 zk.close();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 log.warn("Interrupted on closing zookeeper client", e);
             }
         }
@@ -264,6 +268,7 @@ public void process(WatchedEvent event) {
             throw new IOException("ZK exception checking and wait ephemeral znode "
                     + regPath + " expired", ke);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             log.error("Interrupted checking and wait ephemeral znode {} expired : ", regPath, ie);
             throw new IOException("Interrupted checking and wait ephemeral znode "
                     + regPath + " expired", ie);
@@ -294,6 +299,7 @@ private void doRegisterBookie(String regPath) throws BookieException {
             // exit here as this is a fatal error.
             throw new MetadataStoreException(ke);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             log.error("Interrupted exception registering ephemeral Znode for Bookie!", ie);
             // Throw an IOException back up. This will cause the Bookie
             // constructor to error out. Alternatively, we could do a System
@@ -345,7 +351,10 @@ public void unregisterBookie(String bookieId, boolean readOnly) throws BookieExc
     private void doUnregisterBookie(String regPath) throws BookieException {
         try {
             zk.delete(regPath, -1);
-        } catch (InterruptedException | KeeperException e) {
+        } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
+            throw new MetadataStoreException(ie);
+        } catch (KeeperException e) {
             throw new MetadataStoreException(e);
         }
     }
@@ -378,7 +387,10 @@ public void writeCookie(String bookieId,
                     cookieData.getValue(),
                     (int) ((LongVersion) cookieData.getVersion()).getLongVersion());
             }
-        } catch (InterruptedException | KeeperException e) {
+        } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
+            throw new MetadataStoreException("Interrupted writing cookie for bookie " + bookieId, ie);
+        } catch (KeeperException e) {
             throw new MetadataStoreException("Failed to write cookie for bookie " + bookieId);
         }
     }
@@ -406,7 +418,10 @@ public void removeCookie(String bookieId, Version version) throws BookieExceptio
             zk.delete(zkPath, (int) ((LongVersion) version).getLongVersion());
         } catch (NoNodeException e) {
             throw new CookieNotFoundException(bookieId);
-        } catch (InterruptedException | KeeperException e) {
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            throw new MetadataStoreException("Interrupted deleting cookie for bookie " + bookieId, e);
+        } catch (KeeperException e) {
             throw new MetadataStoreException("Failed to delete cookie for bookie " + bookieId);
         }
 
@@ -608,6 +623,7 @@ public boolean isBookieRegistered(String bookieId) throws BookieException {
             log.error("ZK exception while checking registration ephemeral znodes for BookieId: {}", bookieId, e);
             throw new MetadataStoreException(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             log.error("InterruptedException while checking registration ephemeral znodes for BookieId: {}", bookieId,
                     e);
             throw new MetadataStoreException(e);
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManager.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManager.java
index 59c3f2c37..76ecc9d68 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManager.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManager.java
@@ -267,6 +267,7 @@ LedgerRange getLedgerRangeByLevel(final String level1, final String level2)
                  * return an empty list. */
                 ledgerNodes = new ArrayList<>();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 throw new IOException("Error when get child nodes from zk", e);
             }
             NavigableSet<Long> zkActiveLedgers = ledgerListToSet(ledgerNodes, nodePath);
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongZkLedgerIdGenerator.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongZkLedgerIdGenerator.java
index c2cb07131..d959c337f 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongZkLedgerIdGenerator.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongZkLedgerIdGenerator.java
@@ -103,6 +103,7 @@ public void operationComplete(int rc, Long result) {
                         LOG.error("Failed to create long ledger ID path", e);
                         cb.operationComplete(BKException.Code.ZKException, null);
                     } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
                         LOG.error("Failed to create long ledger ID path", e);
                         cb.operationComplete(BKException.Code.InterruptedException, null);
                     } catch (IOException e) {
@@ -241,6 +242,7 @@ public void processResult(int rc, String path, Object ctx, String name) {
                             setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
                             cb.operationComplete(BKException.Code.ZKException, null);
                         } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
                             LOG.error("Failed to create long ledger ID path", e);
                             setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
                             cb.operationComplete(BKException.Code.InterruptedException, null);
@@ -318,6 +320,7 @@ public void operationComplete(int rc, Long result) {
             LOG.error("Failed to create long ledger ID path", e);
             cb.operationComplete(BKException.Code.ZKException, null);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Failed to create long ledger ID path", e);
             cb.operationComplete(BKException.Code.InterruptedException, null);
         } catch (IOException e) {
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MSLedgerManagerFactory.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MSLedgerManagerFactory.java
index 1d189c9ea..a175cc4f8 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MSLedgerManagerFactory.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MSLedgerManagerFactory.java
@@ -181,6 +181,7 @@ public synchronized void block() {
                     wait();
                 }
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
             }
         }
 
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieNettyServer.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieNettyServer.java
index 83a37776c..bc303b92d 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieNettyServer.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieNettyServer.java
@@ -169,6 +169,7 @@ void suspendProcessing() {
                         try {
                             Thread.sleep(10);
                         } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
                         }
                     }
                 });
@@ -406,6 +407,7 @@ void shutdown() {
             try {
                 eventLoopGroup.shutdownGracefully(0, 10, TimeUnit.MILLISECONDS).await();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 /// OK
             }
         }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
index 602134a98..a12020263 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
@@ -225,6 +225,7 @@ public void run() {
                     Thread.sleep(watchInterval);
                 } catch (InterruptedException ie) {
                     // do nothing
+                    Thread.currentThread().interrupt();
                 }
                 if (!isBookieRunning()) {
                     shutdown();
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ReadEntryProcessor.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ReadEntryProcessor.java
index b450a5a9f..ee1e930e6 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ReadEntryProcessor.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ReadEntryProcessor.java
@@ -93,6 +93,7 @@ protected void processPacket() {
                         errorCode = BookieProtocol.EOK;
                     }
                 } catch (InterruptedException ie) {
+                    Thread.currentThread().interrupt();
                     LOG.error("Interrupting fence read entry {}", read, ie);
                     errorCode = BookieProtocol.EIO;
                     data.release();
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
index b9cb2dad5..75b29bad0 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
@@ -164,6 +164,7 @@ private void initialize(ServerConfiguration conf, ZooKeeper zkc)
             throw new UnavailableException(
                     "Exception while initializing Auditor", ioe);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             throw new UnavailableException(
                     "Interrupted while initializing Auditor", ie);
         }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
index aca74c586..8fbd159be 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
@@ -224,6 +224,7 @@ public void run() {
                         try {
                             zkc.delete(myVote, -1);
                         } catch (InterruptedException ie) {
+                            Thread.currentThread().interrupt();
                             LOG.warn("InterruptedException while deleting myVote: " + myVote,
                                      ie);
                         } catch (KeeperException ke) {
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
index d25e4d3dc..bc9fed1f6 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
@@ -208,6 +208,7 @@ public void run() {
                 try {
                     Thread.sleep(watchInterval);
                 } catch (InterruptedException ie) {
+                    Thread.currentThread().interrupt();
                     break;
                 }
                 // If any one service not running, then shutdown peer.
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
index 8318b2f72..8969aa69b 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
@@ -188,6 +188,7 @@ private static void waitBackOffTime(long backoffMs) {
         try {
             Thread.sleep(backoffMs);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
         }
     }
 
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/SASLBookieAuthProviderFactory.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/SASLBookieAuthProviderFactory.java
index a5fe1d874..250628686 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/SASLBookieAuthProviderFactory.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/SASLBookieAuthProviderFactory.java
@@ -114,6 +114,7 @@ public void close() {
             try {
                 ticketRefreshThread.join(10000);
             } catch (InterruptedException exit) {
+                Thread.currentThread().interrupt();
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("interrupted while waiting for TGT reresh thread to stop", exit);
                 }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/SASLClientProviderFactory.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/SASLClientProviderFactory.java
index 180a9d11c..7fd9b7dcb 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/SASLClientProviderFactory.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/SASLClientProviderFactory.java
@@ -122,6 +122,7 @@ public void close() {
             try {
                 ticketRefreshThread.join(10000);
             } catch (InterruptedException exit) {
+                Thread.currentThread().interrupt();
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("interrupted while waiting for TGT reresh thread to stop", exit);
                 }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/TGTRefreshThread.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/TGTRefreshThread.java
index 480b9e8f2..f4a2508f7 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/TGTRefreshThread.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/sasl/TGTRefreshThread.java
@@ -166,6 +166,7 @@ public void run() {
                 try {
                     Thread.sleep(nextRefresh - now);
                 } catch (InterruptedException ie) {
+                    Thread.currentThread().interrupt();
                     LOG.warn("TGT renewal thread has been interrupted and will exit.");
                     break;
                 }
@@ -195,6 +196,7 @@ public void run() {
                             try {
                                 Thread.sleep(10 * 1000);
                             } catch (InterruptedException ie) {
+                                Thread.currentThread().interrupt();
                                 LOG.error("Interrupted while renewing TGT, exiting Login thread");
                                 return;
                             }
@@ -220,6 +222,7 @@ public void run() {
                             try {
                                 Thread.sleep(10 * 1000);
                             } catch (InterruptedException e) {
+                                Thread.currentThread().interrupt();
                                 LOG.error("Interrupted during login retry after LoginException:", le);
                                 throw le;
                             }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java
index 5ee8bb549..e6c155828 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java
@@ -216,6 +216,7 @@ static int doMain(String[] args) {
         try {
             aliveLatch.await();
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             // the server is interrupted
             log.info("Bookie server is interrupted. Exiting ...");
         }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/BKHttpServiceProvider.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/BKHttpServiceProvider.java
index c6b85d2c1..fb15a5f4d 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/BKHttpServiceProvider.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/BKHttpServiceProvider.java
@@ -105,9 +105,13 @@ public void close() throws IOException {
             if (zk != null) {
                 zk.close();
             }
-        } catch (InterruptedException | BKException e) {
-            log.error("Error while close BKHttpServiceProvider", e);
-            throw new IOException("Error while close BKHttpServiceProvider", e);
+        } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
+            log.error("Interruption while closing BKHttpServiceProvider", ie);
+            throw new IOException("Interruption while closing BKHttpServiceProvider", ie);
+        } catch (BKException e) {
+            log.error("Error while closing BKHttpServiceProvider", e);
+            throw new IOException("Error while closing BKHttpServiceProvider", e);
         }
     }
 
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/shims/zk/ZooKeeperServerShimImpl.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/shims/zk/ZooKeeperServerShimImpl.java
index cc6e2e287..df9d32914 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/shims/zk/ZooKeeperServerShimImpl.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/shims/zk/ZooKeeperServerShimImpl.java
@@ -46,6 +46,7 @@ public void start() throws IOException {
         try {
             serverFactory.startup(zks);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new IOException("Interrupted when starting zookeeper server : ", e);
         }
     }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/HardLink.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/HardLink.java
index 89359c8b9..c8c7a71a3 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/HardLink.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/HardLink.java
@@ -434,6 +434,7 @@ public static void createHardLink(File file, File linkName)
         throw new IOException(errMsg + inpMsg);
       }
     } catch (InterruptedException e) {
+      Thread.currentThread().interrupt();
       throw new IOException(e);
     } finally {
       process.destroy();
@@ -526,6 +527,7 @@ protected static int createHardLinkMult(File parentDir,
         throw new IOException(errMsg + inpMsg);
       }
     } catch (InterruptedException e) {
+      Thread.currentThread().interrupt();
       throw new IOException(e);
     } finally {
       process.destroy();
@@ -574,6 +576,7 @@ public static int getLinkCount(File fileName) throws IOException {
     } catch (NumberFormatException e) {
       throw createIOException(fileName, inpMsg, errMsg, exitValue, e);
     } catch (InterruptedException e) {
+      Thread.currentThread().interrupt();
       throw createIOException(fileName, inpMsg, errMsg, exitValue, e);
     } finally {
       process.destroy();
@@ -660,6 +663,7 @@ public static String makeShellPath(File file) throws IOException {
         r = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8));
         return r.readLine();
       } catch (InterruptedException ie) {
+        Thread.currentThread().interrupt();
         throw new IOException("Couldn't resolve path " + filename, ie);
       } finally {
         if (r != null) {
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/LocalBookKeeper.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/LocalBookKeeper.java
index a735ed8f8..5958c9c29 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/LocalBookKeeper.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/LocalBookKeeper.java
@@ -128,6 +128,7 @@ private void initializeZookeeper(AbstractConfiguration conf, String zkHost, int
             LOG.error("Exception while creating znodes", e);
             throw new IOException("Error creating znodes : ", e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Interrupted while creating znodes", e);
             throw new IOException("Error creating znodes : ", e);
         }
@@ -153,6 +154,7 @@ private static void cleanupDirectories(List<File> dirs) throws IOException {
             cleanupDirectories(tempDirs);
             throw ke;
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             cleanupDirectories(tempDirs);
             throw ie;
         } catch (BookieException be) {
@@ -351,6 +353,7 @@ static void startLocalBookiesInternal(ServerConfiguration conf,
                     Thread.sleep(5000);
                 }
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
                 if (stopOnExit) {
                     lb.shutdownBookies();
 
@@ -497,6 +500,7 @@ public static boolean waitForServerUp(String hp, long timeout) {
             try {
                 Thread.sleep(250);
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 // ignore
             }
         }
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/Shell.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/Shell.java
index a5c4ea126..9e37614a7 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/Shell.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/Shell.java
@@ -168,6 +168,7 @@ public void run() {
                 // make sure that the error thread exits
                 errThread.join();
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
                 LOG.warn("Interrupted while reading the error stream", ie);
             }
             completed.set(true);
@@ -177,6 +178,7 @@ public void run() {
                 throw new ExitCodeException(exitCode, errMsg.toString());
             }
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             throw new IOException(ie.toString());
         } finally {
             if (timeOutTimer != null) {
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/zookeeper/ZooKeeperClient.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/zookeeper/ZooKeeperClient.java
index 0c143da0a..8147817fd 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/zookeeper/ZooKeeperClient.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/zookeeper/ZooKeeperClient.java
@@ -252,6 +252,7 @@ public ZooKeeperClient build() throws IOException, KeeperException, InterruptedE
                 client.close();
                 throw ke;
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
                 client.close();
                 throw ie;
             }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java
index 2ea6544d6..3fbb5c840 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java
@@ -93,6 +93,7 @@ public void testBookieRestartContinuously() throws Exception {
                 LOG.error("Caught BKException", e);
                 fail(e.toString());
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 LOG.error("Caught InterruptedException", e);
                 fail(e.toString());
             }
@@ -127,6 +128,7 @@ public void run() {
                 try {
                     latch.await();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     // Ignore
                 }
                 triggerBookieShutdown(ExitCode.BOOKIE_EXCEPTION);
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/SortedLedgerStorageCheckpointTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/SortedLedgerStorageCheckpointTest.java
index 2dfebdf1f..cf2a49f8c 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/SortedLedgerStorageCheckpointTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/SortedLedgerStorageCheckpointTest.java
@@ -203,6 +203,7 @@ public void testCheckpointAfterEntryLogRotated() throws Exception {
             try {
                 readyLatch.await();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
             }
         });
 
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorageWriteCacheTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorageWriteCacheTest.java
index c2281a7dc..df810826d 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorageWriteCacheTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorageWriteCacheTest.java
@@ -62,6 +62,7 @@ public void flush() throws IOException {
                 try {
                     Thread.sleep(1000);
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     return;
                 }
             } finally {
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/WriteCacheTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/WriteCacheTest.java
index f5b0599ed..75feb3252 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/WriteCacheTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/WriteCacheTest.java
@@ -175,7 +175,10 @@ public void testMultipleWriters() throws Exception {
             executor.submit(() -> {
                 try {
                     barrier.await();
-                } catch (InterruptedException | BrokenBarrierException e) {
+                } catch (InterruptedException ie) {
+                    Thread.currentThread().interrupt();
+                    throw new RuntimeException(ie);
+                } catch (BrokenBarrierException e) {
                     throw new RuntimeException(e);
                 }
 
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientTestsWithBookieErrors.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientTestsWithBookieErrors.java
index 98f1961f4..39ff902c1 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientTestsWithBookieErrors.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientTestsWithBookieErrors.java
@@ -88,6 +88,7 @@ public BookKeeperClientTestsWithBookieErrors() {
             try {
                 Thread.sleep(sleepTime);
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
             }
         };
     }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientZKSessionExpiry.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientZKSessionExpiry.java
index bdcfd2575..b1a8bb66d 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientZKSessionExpiry.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientZKSessionExpiry.java
@@ -60,6 +60,7 @@ public void run() {
                             }
                         }
                     } catch (InterruptedException ie) {
+                        Thread.currentThread().interrupt();
                         return;
                     }
                 }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
index 900a7c2a7..6bb2a2a0a 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
@@ -168,6 +168,7 @@ public void addComplete(int rc, LedgerHandle lh, long entryId, Object ctx) {
                         try {
                             recoverDoneLatch.await();
                         } catch (InterruptedException ie) {
+                            Thread.currentThread().interrupt();
                         }
                     }
                 }
@@ -202,6 +203,7 @@ public void addEntry(ByteBuf entry, boolean ackBeforeSync, WriteCallback cb, Obj
                 try {
                     latch.await();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                 }
                 throw BookieException.create(BookieException.Code.UnauthorizedAccessException);
             }
@@ -226,6 +228,7 @@ public void addEntry(ByteBuf entry, boolean ackBeforeSync, WriteCallback cb, Obj
                 try {
                     latch.await();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                 }
                 // simulate slow adds.
                 throw new IOException("Dead bookie");
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ParallelLedgerRecoveryTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ParallelLedgerRecoveryTest.java
index 8c4953136..238992998 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ParallelLedgerRecoveryTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ParallelLedgerRecoveryTest.java
@@ -115,6 +115,7 @@ public void run() {
                         try {
                             cdl.await();
                         } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
                             LOG.error("Interrupted on waiting latch : ", e);
                         }
                         lm.writeLedgerMetadata(ledgerId, metadata, cb);
@@ -480,6 +481,7 @@ public ByteBuf readEntry(long ledgerId, long entryId) throws IOException, NoLedg
                     try {
                         latch.await();
                     } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
                         // no-op
                     }
                 }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestReadLastConfirmedAndEntry.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestReadLastConfirmedAndEntry.java
index 79a197edd..d78b228ab 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestReadLastConfirmedAndEntry.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestReadLastConfirmedAndEntry.java
@@ -78,6 +78,7 @@ public ByteBuf readEntry(long ledgerId, long entryId)
                     try {
                         Thread.sleep(600000);
                     } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
                         // ignore
                     }
                 } else {
@@ -177,6 +178,7 @@ public long readLastAddConfirmed(long ledgerId) throws IOException {
                 try {
                     readLatch.await();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     // no-op
                 }
             }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/GcLedgersTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/GcLedgersTest.java
index 4bad05248..71854f953 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/GcLedgersTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/GcLedgersTest.java
@@ -130,6 +130,7 @@ public void operationComplete(int rc, Void result) {
                     expected.wait(100);
                 }
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
             }
         }
     }
@@ -209,6 +210,7 @@ public void clean(long ledgerId) {
                             try {
                                 createLatch.await();
                             } catch (InterruptedException ie) {
+                                Thread.currentThread().interrupt();
                             }
                             paused = true;
                         }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/LedgerManagerIteratorTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/LedgerManagerIteratorTest.java
index c82198d7a..9286d6f38 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/LedgerManagerIteratorTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/LedgerManagerIteratorTest.java
@@ -420,6 +420,7 @@ public void checkConcurrentModifications() throws Throwable {
                 try {
                     latch.await();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     fail("Checker interrupted");
                 }
                 while (MathUtils.elapsedNanos(start) < runtime) {
@@ -448,6 +449,7 @@ public void checkConcurrentModifications() throws Throwable {
                 try {
                     latch.await();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     fail("Checker interrupted");
                     e.printStackTrace();
                 }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/metastore/MetastoreTableAsyncToSyncConverter.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/metastore/MetastoreTableAsyncToSyncConverter.java
index 12c6a66f8..b1775e8e7 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/metastore/MetastoreTableAsyncToSyncConverter.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/metastore/MetastoreTableAsyncToSyncConverter.java
@@ -41,6 +41,7 @@ void waitCallback() throws MSException {
             try {
                 countDownLatch.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
                 throw MSException.create(Code.InterruptedException);
             }
 
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java
index 6dccf252e..d08dd8ad8 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java
@@ -240,6 +240,7 @@ public ByteBuf readEntry(long ledgerId, long entryId)
                 try {
                     Thread.sleep(3000);
                 } catch (InterruptedException ie) {
+                    Thread.currentThread().interrupt();
                     throw new IOException("Interrupted waiting", ie);
                 }
                 return super.readEntry(ledgerId, entryId);
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/BookieLedgerIndexTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/BookieLedgerIndexTest.java
index 6aef30d52..843927d96 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/BookieLedgerIndexTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/BookieLedgerIndexTest.java
@@ -213,6 +213,7 @@ public void testEnsembleReformation() throws Exception {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java
index 97b0d976a..63da432bf 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java
@@ -753,6 +753,7 @@ private String getData(String znode) {
         } catch (KeeperException e) {
             LOG.error("Exception while reading data from znode :" + znode);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Exception while reading data from znode :" + znode);
         }
         return "";
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/AsyncLedgerOpsTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/AsyncLedgerOpsTest.java
index a2582c5f6..1f8717b6f 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/AsyncLedgerOpsTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/AsyncLedgerOpsTest.java
@@ -189,6 +189,7 @@ public void testAsyncCreateClose() throws IOException, BKException {
             assertTrue("Checking number of read entries", i == numEntriesToWrite);
             lh.close();
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Interrupted", e);
             fail("InterruptedException");
         } // catch (NoSuchAlgorithmException e) {
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieFailureTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieFailureTest.java
index 2e4cf0354..8a18127a2 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieFailureTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieFailureTest.java
@@ -236,6 +236,7 @@ void auxTestReadWriteAsyncSingleClient(BookieServer bs) throws IOException {
             LOG.error("Caught BKException", e);
             fail(e.toString());
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Caught InterruptedException", e);
             fail(e.toString());
         }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java
index 312af3940..afcb4b475 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java
@@ -261,6 +261,7 @@ private void testReadWriteAsyncSingleClient(int numEntries) throws IOException {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -397,6 +398,7 @@ public void testReadWriteRangeAsyncSingleClient() throws IOException {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -491,6 +493,7 @@ public void testSyncReadAsyncWriteStringsSingleClient() throws IOException {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -535,6 +538,7 @@ public void testReadWriteSyncSingleClient() throws IOException {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -591,6 +595,7 @@ public void addComplete(int rccb, LedgerHandle lh, long entryId, Object ctx) {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -664,6 +669,7 @@ public void addComplete(int rc2, LedgerHandle lh, long entryId, Object ctx) {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -715,6 +721,7 @@ public void testReadWriteAsyncLength() throws IOException {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -829,6 +836,7 @@ public void testReadFromOpenLedger() throws Exception {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -885,6 +893,7 @@ public void testReadFromOpenLedgerOpenOnce() throws Exception {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -952,6 +961,7 @@ public void testReadFromOpenLedgerZeroAndOne() throws Exception {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
@@ -1130,6 +1140,7 @@ public void testLastConfirmedAdd() throws Exception {
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/MultipleThreadReadTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/MultipleThreadReadTest.java
index 9e083da32..1d3929ca0 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/MultipleThreadReadTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/MultipleThreadReadTest.java
@@ -286,6 +286,7 @@ public void multiLedgerMultiThreadRead(final int numLedgers,
             LOG.error("Test failed", e);
             fail("Test failed due to BookKeeper exception");
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             LOG.error("Test failed", e);
             fail("Test failed due to interruption");
         }
diff --git a/stream/distributedlog/common/src/main/java/org/apache/distributedlog/common/util/SchedulerUtils.java b/stream/distributedlog/common/src/main/java/org/apache/distributedlog/common/util/SchedulerUtils.java
index f6d4f230c..e85db394d 100644
--- a/stream/distributedlog/common/src/main/java/org/apache/distributedlog/common/util/SchedulerUtils.java
+++ b/stream/distributedlog/common/src/main/java/org/apache/distributedlog/common/util/SchedulerUtils.java
@@ -35,6 +35,7 @@ public static void shutdownScheduler(ExecutorService service, long timeout, Time
         try {
             service.awaitTermination(timeout, timeUnit);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             log.warn("Interrupted when shutting down scheduler : ", e);
         }
         service.shutdownNow();
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClient.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClient.java
index 33baa9de7..ee16e5d51 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClient.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClient.java
@@ -168,6 +168,7 @@ private synchronized void initialize() throws IOException {
         try {
             commonInitialization(conf, ledgersPath, eventLoopGroup, statsLogger, requestTimer);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted on creating bookkeeper client " + name + " : ", e);
         }
 
@@ -267,6 +268,7 @@ public void close() {
             try {
                 bkcToClose.close();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 LOG.warn("Interrupted on closing bookkeeper client {} : ", name, e);
                 Thread.currentThread().interrupt();
             } catch (BKException e) {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/LocalDLMEmulator.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/LocalDLMEmulator.java
index ff7e953fd..dc014f1b3 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/LocalDLMEmulator.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/LocalDLMEmulator.java
@@ -147,6 +147,7 @@ public void run() {
                             numBookies, shouldStartZK, initialBookiePort, serverConf);
                     LOG.info("{} bookies are started.");
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     // go away quietly
                 } catch (Exception e) {
                     LOG.error("Error starting local bk", e);
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/LogSegmentMetadata.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/LogSegmentMetadata.java
index 0e4a2f094..a9b38841f 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/LogSegmentMetadata.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/LogSegmentMetadata.java
@@ -649,6 +649,7 @@ public void processResult(int rc, String path, Object ctx, byte[] data, Stat sta
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             result.completeExceptionally(Utils.zkException(e, path));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             result.completeExceptionally(Utils.zkException(e, path));
         }
         return result;
@@ -1013,6 +1014,7 @@ public void write(ZooKeeperClient zkc)
         } catch (KeeperException.NodeExistsException nee) {
             throw nee;
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted on creating ledger znode " + zkPath, ie);
         } catch (Exception e) {
             LOG.error("Error creating ledger znode {}", zkPath, e);
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadAheadEntryReader.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadAheadEntryReader.java
index 1d3fbceab..33ff9915d 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadAheadEntryReader.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/ReadAheadEntryReader.java
@@ -630,6 +630,7 @@ private synchronized void pauseReadAheadOnNoMoreLogSegments() {
         try {
             entry = entryQueue.poll(waitTime, waitTimeUnit);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted on waiting next readahead entry : ", e);
         }
         try {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/auditor/DLAuditor.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/auditor/DLAuditor.java
index 192e6e175..695f6e834 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/auditor/DLAuditor.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/auditor/DLAuditor.java
@@ -323,6 +323,7 @@ public void execute(String poolPath) throws IOException {
                 try {
                     collectLedgersFromPool(poolPath);
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     throw new DLInterruptedException("Interrupted on collecting"
                             + " ledgers from allocation pool " + poolPath, e);
                 } catch (KeeperException e) {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/LedgerAllocatorPool.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/LedgerAllocatorPool.java
index b9f3a72b3..9f3668762 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/LedgerAllocatorPool.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/LedgerAllocatorPool.java
@@ -145,6 +145,7 @@ private void initializePool() throws IOException {
             }
             initializeAllocators(allocators);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted when ensuring " + poolPath + " created : ", ie);
         } catch (KeeperException ke) {
             throw new IOException("Encountered zookeeper exception when initializing pool " + poolPath + " : ", ke);
@@ -278,6 +279,7 @@ public void processResult(int rc, String path, Object ctx, byte[] data, Stat sta
                 }
             }, null);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             logger.warn("Interrupted on rescuing ledger allocator {} : ", ledgerAllocator.allocatePath, ie);
             synchronized (LedgerAllocatorPool.this) {
                 rescueMap.remove(ledgerAllocator.allocatePath);
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java
index 7a9fa5868..aa0bc012d 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java
@@ -150,6 +150,7 @@ public void processResult(int rc, String path, Object ctx, String name, Stat sta
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             return FutureUtils.exception(Utils.zkException(e, allocatePath));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             return FutureUtils.exception(Utils.zkException(e, allocatePath));
         }
     }
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/BKNamespaceDriver.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/BKNamespaceDriver.java
index 293ac2a0c..17f3e7ba4 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/BKNamespaceDriver.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/BKNamespaceDriver.java
@@ -559,6 +559,7 @@ public SubscriptionsStore getSubscriptionsStore(String streamName) {
                 }
             }
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             LOG.error("Interrupted while deleting " + namespaceRootPath, ie);
             throw new IOException("Interrupted while reading " + namespaceRootPath, ie);
         } catch (KeeperException ke) {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogMetadataStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogMetadataStore.java
index 32e7ab7e6..fbbf2ab92 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogMetadataStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogMetadataStore.java
@@ -119,6 +119,7 @@ public void processResult(int rc, String path, Object ctx,
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         }
         return promise;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java
index b57a02770..1b5e5d5bb 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java
@@ -360,6 +360,7 @@ public void process(WatchedEvent event) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             result.completeExceptionally(Utils.zkException(e, logSegmentsPath));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             result.completeExceptionally(Utils.zkException(e, logSegmentsPath));
         }
         return result;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKMetadataAccessor.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKMetadataAccessor.java
index 481d398de..37a9eca92 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKMetadataAccessor.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKMetadataAccessor.java
@@ -171,6 +171,7 @@ public void createOrUpdateMetadata(byte[] metadata) throws IOException {
                 writerZKC.get().setData(zkPath, metadata, currentStat.getVersion());
             }
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted on creating or updating container metadata", ie);
         } catch (Exception exc) {
             throw new IOException("Exception creating or updating container metadata", exc);
@@ -206,6 +207,7 @@ public void deleteMetadata() throws IOException {
                 return readerZKC.get().getData(zkPath, false, currentStat);
             }
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Error reading the max tx id from zk", ie);
         } catch (Exception e) {
             throw new IOException("Error reading the max tx id from zk", e);
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKNamespaceWatcher.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKNamespaceWatcher.java
index f14c5bd05..6bd974507 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKNamespaceWatcher.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKNamespaceWatcher.java
@@ -94,6 +94,7 @@ private void doWatchNamespaceChanges() {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             scheduleTask(this, conf.getZKSessionTimeoutMilliseconds());
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             logger.warn("Interrupted on watching namespace changes for {} : ", uri, e);
             scheduleTask(this, conf.getZKSessionTimeoutMilliseconds());
         }
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControl.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControl.java
index ffc6e575c..22efb7e61 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControl.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControl.java
@@ -122,6 +122,7 @@ public void processResult(int rc, String path, Object ctx, String name) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         } catch (IOException e) {
             promise.completeExceptionally(e);
@@ -146,6 +147,7 @@ public void processResult(int rc, String path, Object ctx, Stat stat) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         } catch (IOException e) {
             promise.completeExceptionally(e);
@@ -176,6 +178,7 @@ public void processResult(int rc, String path, Object ctx, byte[] data, Stat sta
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         }
         return promise;
@@ -199,6 +202,7 @@ public void processResult(int rc, String path, Object ctx) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         }
         return promise;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControlManager.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControlManager.java
index 83e355fa3..925b14dc9 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControlManager.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/acl/ZKAccessControlManager.java
@@ -218,6 +218,7 @@ private void complete() {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         }
     }
@@ -260,6 +261,7 @@ private void createDefaultAccessControlEntryIfNeeded(final CompletableFuture<ZKA
             promise.completeExceptionally(e);
             return;
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
             return;
         }
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/federated/FederatedZKLogMetadataStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/federated/FederatedZKLogMetadataStore.java
index 84f5ac773..ef55f4d88 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/federated/FederatedZKLogMetadataStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/federated/FederatedZKLogMetadataStore.java
@@ -306,6 +306,7 @@ public void processResult(int rc, String path, Object ctx) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         }
         return promise;
@@ -343,6 +344,7 @@ public void processResult(int rc, String path, Object ctx, List<String> children
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         }
     }
@@ -540,6 +542,7 @@ public void processResult(int rc, String path, Object ctx, String name) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             promise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             promise.completeExceptionally(e);
         }
 
@@ -568,6 +571,7 @@ public void run() {
                     createLogInNamespaceSync(uri, logName);
                     createPromise.complete(uri);
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     createPromise.completeExceptionally(e);
                 } catch (IOException e) {
                     createPromise.completeExceptionally(e);
@@ -709,6 +713,7 @@ public void processResult(int rc, String path, Object ctx, Stat stat) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             fetchPromise.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             fetchPromise.completeExceptionally(e);
         }
         return fetchPromise;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZKLogStreamMetadataStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZKLogStreamMetadataStore.java
index c046fc620..d8d7674e8 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZKLogStreamMetadataStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZKLogStreamMetadataStore.java
@@ -213,6 +213,7 @@ public void processResult(int rc, String path, Object ctx, Stat stat) {
             }, null);
 
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             LOG.error("Interrupted while reading {}", logSegmentsPath, ie);
             promise.completeExceptionally(new DLInterruptedException("Interrupted while checking "
                     + logSegmentsPath, ie));
@@ -616,6 +617,7 @@ static LogMetadataForWriter processLogMetadatas(URI uri,
                     new ZKException("Encountered zookeeper connection issue on creating log "
                             + logName, KeeperException.Code.CONNECTIONLOSS));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             return FutureUtils.exception(new DLInterruptedException("Interrupted on creating log " + logName, e));
         }
     }
@@ -660,6 +662,7 @@ public void processResult(int rc, String path, Object ctx) {
                     new ZKException("Encountered zookeeper issue on deleting log stream "
                             + logName, KeeperException.Code.CONNECTIONLOSS));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             FutureUtils.completeExceptionally(promise,
                     new DLInterruptedException("Interrupted while deleting log stream " + logName));
         } catch (KeeperException e) {
@@ -872,6 +875,7 @@ private static void existPath(ZooKeeper zk,
         } catch (ZooKeeperConnectionException e) {
             future.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             future.completeExceptionally(e);
         }
         return future;
@@ -940,6 +944,7 @@ private static void deleteOldPathAndCreateNewPath(String oldRootPath,
         } catch (ZooKeeperConnectionException e) {
             future.completeExceptionally(e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             future.completeExceptionally(e);
         }
         return future;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZkMetadataResolver.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZkMetadataResolver.java
index aaa546109..ca1dad313 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZkMetadataResolver.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/metadata/ZkMetadataResolver.java
@@ -59,6 +59,7 @@ public DLMetadata resolve(URI uri) throws IOException {
             } catch (KeeperException ke) {
                 throw new IOException("Fail to resolve dl path : " + pathToResolve);
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
                 throw new IOException("Interrupted when resolving dl path : " + pathToResolve);
             }
             if (null == data || data.length == 0) {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/subscription/ZKSubscriptionStateStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/subscription/ZKSubscriptionStateStore.java
index 5354ac5c4..dd8754ddd 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/subscription/ZKSubscriptionStateStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/subscription/ZKSubscriptionStateStore.java
@@ -93,6 +93,7 @@ public void processResult(int rc, String path, Object ctx, byte[] data, Stat sta
         } catch (ZooKeeperClient.ZooKeeperConnectionException zkce) {
             result.completeExceptionally(zkce);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             result.completeExceptionally(new DLInterruptedException("getLastCommitPosition was interrupted", ie));
         }
         return result;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/subscription/ZKSubscriptionsStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/subscription/ZKSubscriptionsStore.java
index ad4d7b31e..c2c90fcfe 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/subscription/ZKSubscriptionsStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/subscription/ZKSubscriptionsStore.java
@@ -101,6 +101,7 @@ public void processResult(int rc, String path, Object ctx, List<String> children
         } catch (ZooKeeperClient.ZooKeeperConnectionException zkce) {
             result.completeExceptionally(zkce);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             result.completeExceptionally(new DLInterruptedException("getLastCommitPositions was interrupted", ie));
         }
         return result;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/injector/RandomDelayFailureInjector.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/injector/RandomDelayFailureInjector.java
index 7fc567e69..e11794d1b 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/injector/RandomDelayFailureInjector.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/injector/RandomDelayFailureInjector.java
@@ -54,6 +54,7 @@ public void inject() {
                 Thread.sleep(delayMs());
             }
         } catch (InterruptedException ex) {
+            Thread.currentThread().interrupt();
             LOG.warn("delay was interrupted ", ex);
         }
     }
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java
index d9f3b2c08..2d92152bb 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/lock/ZKSessionLock.java
@@ -322,6 +322,7 @@ public ZKSessionLock(ZooKeeperClient zkClient,
             throw new ZKException("Failed to get zookeeper client for lock " + lockPath,
                     KeeperException.Code.CONNECTIONLOSS);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted on getting zookeeper client for lock " + lockPath, e);
         }
         this.lockPath = lockPath;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/metadata/DLMetadata.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/metadata/DLMetadata.java
index 0bb2079ac..ca4c36f9a 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/metadata/DLMetadata.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/metadata/DLMetadata.java
@@ -118,6 +118,7 @@ public void update(URI uri) throws IOException {
             throw new IOException("Fail to update dl metadata " + new String(data, UTF_8)
                     + " to uri " + uri, e);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new IOException("Interrupted when updating dl metadata "
                     + new String(data, UTF_8) + " to uri " + uri, e);
         } finally {
@@ -169,6 +170,7 @@ public static void unbind(URI uri) throws IOException {
         } catch (KeeperException ke) {
             throw new IOException("Fail to unbound dl metadata on uri " + uri, ke);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             throw new IOException("Interrupted when unbinding dl metadata on uri " + uri, ie);
         } finally {
             zkc.close();
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/util/Utils.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/util/Utils.java
index 8b18e02a8..155baaff8 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/util/Utils.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/util/Utils.java
@@ -120,6 +120,7 @@ public static void zkCreateFullPathOptimistic(
         } catch (KeeperException ke) {
             throw ke;
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted on create zookeeper path " + path, ie);
         } catch (RuntimeException rte) {
             throw rte;
@@ -194,6 +195,7 @@ public void processResult(int rc, String path, Object ctx, String name) {
             callback.processResult(DistributedLogConstants.ZK_CONNECTION_EXCEPTION_RESULT_CODE,
                     zkce.getMessage(), ctx, pathToCreate);
         } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
             callback.processResult(DistributedLogConstants.DL_INTERRUPTED_EXCEPTION_RESULT_CODE,
                     ie.getMessage(), ctx, pathToCreate);
         }
@@ -316,6 +318,7 @@ private static void handleKeeperExceptionCode(int rc, String pathOrMessage, Comp
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             return FutureUtils.exception(zkException(e, path));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             return FutureUtils.exception(zkException(e, path));
         }
         return zkGetData(zk, path, watch);
@@ -359,6 +362,7 @@ public void processResult(int rc, String path, Object ctx, byte[] data, Stat sta
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             return FutureUtils.exception(zkException(e, path));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             return FutureUtils.exception(zkException(e, path));
         }
         return zkSetData(zk, path, data, version);
@@ -402,6 +406,7 @@ public void processResult(int rc, String path, Object ctx, Stat stat) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             return FutureUtils.exception(zkException(e, path));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             return FutureUtils.exception(zkException(e, path));
         }
         return zkDelete(zk, path, version);
@@ -455,6 +460,7 @@ public void processResult(int rc, String path, Object ctx) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             return FutureUtils.exception(zkException(e, path));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             return FutureUtils.exception(zkException(e, path));
         }
         final CompletableFuture<Boolean> promise = new CompletableFuture<Boolean>();
@@ -499,6 +505,7 @@ public static ZooKeeper sync(ZooKeeperClient zkc, String path) throws IOExceptio
         try {
             zk = zkc.get();
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted on checking if log " + path + " exists", e);
         }
         final CountDownLatch syncLatch = new CountDownLatch(1);
@@ -513,6 +520,7 @@ public void processResult(int rc, String path, Object ctx) {
         try {
             syncLatch.await();
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new DLInterruptedException("Interrupted on syncing zookeeper connection", e);
         }
         if (KeeperException.Code.OK.intValue() != syncResult.get()) {
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/zk/ZKTransaction.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/zk/ZKTransaction.java
index 350290604..bd2a2d12d 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/zk/ZKTransaction.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/zk/ZKTransaction.java
@@ -68,6 +68,7 @@ public void addOp(Op<Object> operation) {
         } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
             result.completeExceptionally(Utils.zkException(e, ""));
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             result.completeExceptionally(Utils.zkException(e, ""));
         }
         return result;
diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/zk/ZKWatcherManager.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/zk/ZKWatcherManager.java
index 759cf7928..fe8eed421 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/zk/ZKWatcherManager.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/zk/ZKWatcherManager.java
@@ -182,6 +182,7 @@ public void processResult(int rc, String path, Object ctx) {
                         }, null);
                     }
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     logger.debug("Encountered exception on removing watches from {}", path, e);
                 } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
                     logger.debug("Encountered exception on removing watches from {}", path, e);
diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKLogSegmentWriter.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKLogSegmentWriter.java
index eca283d29..7b04b254e 100644
--- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKLogSegmentWriter.java
+++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestBKLogSegmentWriter.java
@@ -532,6 +532,7 @@ public void testAbortShouldFailAllWrites() throws Exception {
             try {
                 deferLatch.await();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 LOG.warn("Interrupted on deferring completion : ", e);
             }
         });
diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestNonBlockingReadsMultiReader.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestNonBlockingReadsMultiReader.java
index 0fd1da43a..854465ba5 100644
--- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestNonBlockingReadsMultiReader.java
+++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestNonBlockingReadsMultiReader.java
@@ -75,6 +75,7 @@ void stopReading() {
             try {
                 join();
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 LOG.error("Interrupted on waiting reader thread {} exiting : ", getName(), e);
             }
         }
diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestZooKeeperClient.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestZooKeeperClient.java
index 777e9ec1a..5f3dae407 100644
--- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestZooKeeperClient.java
+++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/TestZooKeeperClient.java
@@ -448,6 +448,7 @@ public void run() {
                 try {
                     latch.await();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                 }
             }
         });
diff --git a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/lock/TestZKSessionLock.java b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/lock/TestZKSessionLock.java
index ea13cceca..9e4e1e265 100644
--- a/stream/distributedlog/core/src/test/java/org/apache/distributedlog/lock/TestZKSessionLock.java
+++ b/stream/distributedlog/core/src/test/java/org/apache/distributedlog/lock/TestZKSessionLock.java
@@ -325,6 +325,7 @@ public boolean checkFailPoint() throws IOException {
             try {
                 Thread.sleep(timeout);
             } catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
             }
             return true;
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services