File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/java/org/springframework/retry/backoff
test/java/org/springframework/retry/annotation Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -267,7 +267,10 @@ public BackOffPolicy build() {
267267 return policy ;
268268 }
269269 FixedBackOffPolicy policy = new FixedBackOffPolicy ();
270- if (this .delay != null ) {
270+ if (this .delaySupplier != null ) {
271+ policy .backOffPeriodSupplier (this .delaySupplier );
272+ }
273+ else if (this .delay != null ) {
271274 policy .setBackOffPeriod (this .delay );
272275 }
273276 if (this .sleeper != null ) {
Original file line number Diff line number Diff line change 3737import org .springframework .retry .RetryContext ;
3838import org .springframework .retry .RetryListener ;
3939import org .springframework .retry .backoff .ExponentialBackOffPolicy ;
40+ import org .springframework .retry .backoff .FixedBackOffPolicy ;
4041import org .springframework .retry .backoff .Sleeper ;
4142import org .springframework .retry .interceptor .RetryInterceptorBuilder ;
4243import org .springframework .retry .policy .SimpleRetryPolicy ;
@@ -257,6 +258,11 @@ public void testExpression() throws Exception {
257258 assertThat (retryPolicy .getMaxAttempts ()).isEqualTo (5 );
258259 service .service4 ();
259260 assertThat (service .getCount ()).isEqualTo (11 );
261+ interceptor = delegates .get (target (service )).get (ExpressionService .class .getDeclaredMethod ("service4" ));
262+ template = (RetryTemplate ) new DirectFieldAccessor (interceptor ).getPropertyValue ("retryOperations" );
263+ templateAccessor = new DirectFieldAccessor (template );
264+ FixedBackOffPolicy fbp = (FixedBackOffPolicy ) templateAccessor .getPropertyValue ("backOffPolicy" );
265+ assertThat (fbp .getBackOffPeriod ()).isEqualTo (5000L );
260266 service .service5 ();
261267 assertThat (service .getCount ()).isEqualTo (12 );
262268 context .close ();
@@ -762,7 +768,8 @@ public void service3() {
762768 }
763769 }
764770
765- @ Retryable (exceptionExpression = "message.contains('this can be retried')" )
771+ @ Retryable (exceptionExpression = "message.contains('this can be retried')" ,
772+ backoff = @ Backoff (delayExpression = "5000" ))
766773 public void service4 () {
767774 if (this .count ++ < 10 ) {
768775 throw new RuntimeException ("this can be retried" );
You can’t perform that action at this time.
0 commit comments