File tree Expand file tree Collapse file tree 2 files changed +28
-15
lines changed
main/java/com/uber/cadence/common
test/java/com/uber/cadence/internal/common Expand file tree Collapse file tree 2 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -92,22 +92,9 @@ public final RetryOptions addDoNotRetry(Class<? extends Throwable>... doNotRetry
9292 return this ;
9393 }
9494
95- double backoffCoefficient = getBackoffCoefficient ();
96- if (backoffCoefficient == 0 ) {
97- backoffCoefficient = DEFAULT_BACKOFF_COEFFICIENT ;
98- }
99-
100- RetryOptions .Builder builder =
101- new RetryOptions .Builder ()
102- .setInitialInterval (getInitialInterval ())
103- .setExpiration (getExpiration ())
104- .setMaximumInterval (getMaximumInterval ())
105- .setBackoffCoefficient (backoffCoefficient )
106- .setDoNotRetry (merge (getDoNotRetry (), Arrays .asList (doNotRetry )));
95+ RetryOptions .Builder builder = new RetryOptions .Builder (this );
96+ builder .setDoNotRetry (merge (getDoNotRetry (), Arrays .asList (doNotRetry )));
10797
108- if (getMaximumAttempts () > 0 ) {
109- builder .setMaximumAttempts (getMaximumAttempts ());
110- }
11198 return builder .validateBuildWithDefaults ();
11299 }
113100
Original file line number Diff line number Diff line change @@ -107,6 +107,32 @@ public void testInterruptedException() throws InterruptedException {
107107 assertTrue (System .currentTimeMillis () - start < 100000 );
108108 }
109109
110+ @ Test
111+ public void testAddDoNotRetry () throws InterruptedException {
112+ RetryOptions options =
113+ new RetryOptions .Builder ()
114+ .setInitialInterval (Duration .ofMillis (10 ))
115+ .setExpiration (Duration .ofSeconds (100 ))
116+ .validateBuildWithDefaults ();
117+ options = options .addDoNotRetry (InterruptedException .class );
118+ long start = System .currentTimeMillis ();
119+ try {
120+ Retryer .retryWithResultAsync (
121+ options ,
122+ () -> {
123+ CompletableFuture <Void > result = new CompletableFuture <>();
124+ result .completeExceptionally (new InterruptedException ("simulated" ));
125+ return result ;
126+ })
127+ .get ();
128+ fail ("unreachable" );
129+ } catch (ExecutionException e ) {
130+ assertTrue (e .getCause () instanceof InterruptedException );
131+ assertEquals ("simulated" , e .getCause ().getMessage ());
132+ }
133+ assertTrue (System .currentTimeMillis () - start < 100000 );
134+ }
135+
110136 @ Test
111137 public void testMaxAttempt () throws InterruptedException {
112138 RetryOptions options =
You can’t perform that action at this time.
0 commit comments