diff --git a/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentLongLongPairHashMapTest.java b/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentLongLongPairHashMapTest.java index e2d7c77f51622..7b7255bacc854 100644 --- a/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentLongLongPairHashMapTest.java +++ b/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentLongLongPairHashMapTest.java @@ -203,7 +203,7 @@ public void testConcurrentExpandAndShrinkAndGet() throws Throwable { } catch (Exception e) { throw new RuntimeException(e); } - while (true) { + while (!Thread.currentThread().isInterrupted()) { try { map.get(1, 1); } catch (Exception e) { diff --git a/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentLongPairSetTest.java b/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentLongPairSetTest.java index 9c8655b21cfb3..0287e986b004d 100644 --- a/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentLongPairSetTest.java +++ b/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentLongPairSetTest.java @@ -239,7 +239,7 @@ public void testConcurrentExpandAndShrinkAndGet() throws Throwable { } catch (Exception e) { throw new RuntimeException(e); } - while (true) { + while (!Thread.currentThread().isInterrupted()) { try { set.contains(1, 1); } catch (Exception e) { diff --git a/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentOpenHashMapTest.java b/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentOpenHashMapTest.java index 8ff00a022b3cb..48a1a705a3202 100644 --- a/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentOpenHashMapTest.java +++ b/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentOpenHashMapTest.java @@ -243,7 +243,7 @@ public void testConcurrentExpandAndShrinkAndGet() throws Throwable { } catch (Exception e) { throw new RuntimeException(e); } - while (true) { + while (!Thread.currentThread().isInterrupted()) { try { map.get("k2"); } catch (Exception e) { diff --git a/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentOpenHashSetTest.java b/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentOpenHashSetTest.java index 29722ed782127..d509002e21998 100644 --- a/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentOpenHashSetTest.java +++ b/pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/ConcurrentOpenHashSetTest.java @@ -214,7 +214,7 @@ public void testConcurrentExpandAndShrinkAndGet() throws Throwable { } catch (Exception e) { throw new RuntimeException(e); } - while (true) { + while (!Thread.currentThread().isInterrupted()) { try { set.contains("k2"); } catch (Exception e) {