From d820508a016d620aed2cd9ad038525a74b30841c Mon Sep 17 00:00:00 2001 From: Mahmoud Romeh Date: Tue, 16 Oct 2018 11:07:35 +0200 Subject: [PATCH] #259 FIXING code quality issues --- .../github/resilience4j/retry/internal/RetryImpl.java | 11 +---------- .../resilience4j/retry/internal/AsyncRetryTest.java | 5 ++++- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/resilience4j-retry/src/main/java/io/github/resilience4j/retry/internal/RetryImpl.java b/resilience4j-retry/src/main/java/io/github/resilience4j/retry/internal/RetryImpl.java index 69a5eb5de0..b98c1bb6f3 100644 --- a/resilience4j-retry/src/main/java/io/github/resilience4j/retry/internal/RetryImpl.java +++ b/resilience4j-retry/src/main/java/io/github/resilience4j/retry/internal/RetryImpl.java @@ -96,7 +96,7 @@ public boolean onResult(T result) { if (currentNumOfAttempts >= maxAttempts) { return false; } else { - waitIntervalAfterResultFailure(currentNumOfAttempts, result); + waitIntervalAfterFailure(currentNumOfAttempts, null); return true; } } @@ -157,15 +157,6 @@ private void waitIntervalAfterFailure(int currentNumOfAttempts, Throwable throwa .getOrElseThrow(ex -> lastRuntimeException.get()); } - private void waitIntervalAfterResultFailure(int currentNumOfAttempts, T result) { - // wait interval until the next attempt should start - long interval = intervalFunction.apply(numOfAttempts.get()); - publishRetryEvent(() -> new RetryOnRetryEvent(getName(), currentNumOfAttempts, null, interval)); - Try.run(() -> sleepFunction.accept(interval)) - .getOrElseThrow(ex -> lastRuntimeException.get()); - - } - } /** diff --git a/resilience4j-retry/src/test/java/io/github/resilience4j/retry/internal/AsyncRetryTest.java b/resilience4j-retry/src/test/java/io/github/resilience4j/retry/internal/AsyncRetryTest.java index 0c878a9473..7ece6e2c61 100644 --- a/resilience4j-retry/src/test/java/io/github/resilience4j/retry/internal/AsyncRetryTest.java +++ b/resilience4j-retry/src/test/java/io/github/resilience4j/retry/internal/AsyncRetryTest.java @@ -14,6 +14,7 @@ import javax.xml.ws.WebServiceException; import org.assertj.core.api.Assertions; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.BDDMockito; @@ -75,6 +76,8 @@ public void shouldNotRetryWithThatResult() throws InterruptedException, Executio // Then the helloWorldService should be invoked 1 time BDDMockito.then(helloWorldService).should(Mockito.times(1)).returnHelloWorld(); Assertions.assertThat(result).isEqualTo("Hello world"); + // for code quality scan , it does not not recognize assertJ do not why + Assert.assertEquals(result, "Hello world"); } @Test @@ -250,7 +253,7 @@ private void shouldCompleteFutureAfterAttemptsInCaseOfRetyOnResultAtAsyncStage(i // Then the helloWorldService should be invoked n + 1 times BDDMockito.then(helloWorldService).should(Mockito.times(noOfAttempts)).returnHelloWorld(); - Assertions.assertThat(resultTry.isSuccess()).isTrue(); + Assert.assertTrue(resultTry.isSuccess()); }