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
92
92
return this ;
93
93
}
94
94
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 )));
107
97
108
- if (getMaximumAttempts () > 0 ) {
109
- builder .setMaximumAttempts (getMaximumAttempts ());
110
- }
111
98
return builder .validateBuildWithDefaults ();
112
99
}
113
100
Original file line number Diff line number Diff line change @@ -107,6 +107,32 @@ public void testInterruptedException() throws InterruptedException {
107
107
assertTrue (System .currentTimeMillis () - start < 100000 );
108
108
}
109
109
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
+
110
136
@ Test
111
137
public void testMaxAttempt () throws InterruptedException {
112
138
RetryOptions options =
You can’t perform that action at this time.
0 commit comments