diff --git a/server/src/test/java/org/opensearch/common/blobstore/stream/read/listener/ReadContextListenerTests.java b/server/src/test/java/org/opensearch/common/blobstore/stream/read/listener/ReadContextListenerTests.java index f785b5f1191b4..936e2170bed6c 100644 --- a/server/src/test/java/org/opensearch/common/blobstore/stream/read/listener/ReadContextListenerTests.java +++ b/server/src/test/java/org/opensearch/common/blobstore/stream/read/listener/ReadContextListenerTests.java @@ -70,7 +70,7 @@ public void testReadContextListener() throws InterruptedException, IOException { assertEquals(NUMBER_OF_PARTS * PART_SIZE, Files.size(fileLocation)); } - public void testReadContextListenerFailure() throws InterruptedException { + public void testReadContextListenerFailure() throws Exception { Path fileLocation = path.resolve(UUID.randomUUID().toString()); List blobPartStreams = initializeBlobPartStreams(); CountDownLatch countDownLatch = new CountDownLatch(1); @@ -99,8 +99,7 @@ public int available() { readContextListener.onResponse(readContext); countDownLatch.await(); - - assertFalse(Files.exists(fileLocation)); + assertBusy(() -> { assertFalse(Files.exists(fileLocation)); }); } public void testReadContextListenerException() {