Skip to content

Commit

Permalink
[bluetooth] Try to make tests more stable No.2 (#9309)
Browse files Browse the repository at this point in the history
* [bluetooth] Try to make tests more stable No.2

Signed-off-by: Fabian Wolter <[email protected]>
  • Loading branch information
fwolter authored Dec 10, 2020
1 parent 3bd17f4 commit 941189a
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void composeWithRetryThrow() {
}

@Test
void composeWithRetry1() throws InterruptedException {
void composeWithRetry1() {
AtomicInteger visitCount = new AtomicInteger();
CompletableFuture<String> composedFuture = new CompletableFuture<>();
Future<String> retryFuture = RetryFuture.composeWithRetry(() -> {
Expand Down Expand Up @@ -152,11 +152,12 @@ void composeWithRetry1Cancel() {
if (!latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
fail("Timeout while waiting for latch");
}
Thread.sleep(1);
retryFuture.cancel(false);

assertTrue(composedFuture.isCancelled());
} catch (InterruptedException e) {
Future<Boolean> future = scheduler.submit(() -> {
retryFuture.cancel(false);
return composedFuture.isCancelled();
});
assertTrue(future.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
} catch (InterruptedException | ExecutionException | TimeoutException e) {
fail(e);
}
assertEquals(2, visitCount.get());
Expand Down

0 comments on commit 941189a

Please sign in to comment.