@ Override public boolean canRetry ( RetryContext context ) { RetryContext [ ] contexts = ( ( CompositeRetryContext ) context ) . contexts ; RetryPolicy [ ] policies = ( ( CompositeRetryContext ) context ) . policies ; boolean retryable = true ; if ( this . optimistic ) { retryable = false ; for ( int i = 0 ; i < contexts . length ; i ++ ) { if ( policies [ i ] . canRetry ( contexts [ i ] ) ) { retryable = true ; } } } else { for ( int i = 0 ; i < contexts . length ; i ++ ) { if ( ! policies [ i ] . canRetry ( contexts [ i ] ) ) { retryable = false ; } } } return retryable ; }
Delegate to the policies that were in operation when the context was created . If any of them cannot retry then return false otherwise return true .