/** * Creates a next attempt {@link TimedAttemptSettings}. This method will return first non-null * value, returned by either result or timed retry algorithms in that particular order. * * @param prevThrowable exception thrown by the previous attempt or null if a result was returned * instead * @param prevResponse response returned by the previous attempt or null if an exception was * thrown instead * @param prevSettings previous attempt settings * @return next attempt settings, can be {@code null}, if no there should be no new attempt */ public TimedAttemptSettings createNextAttempt( Throwable prevThrowable, ResponseT prevResponse, TimedAttemptSettings prevSettings) { // a small optimization, which allows to avoid calling relatively heavy methods // like timedAlgorithm.createNextAttempt(), when it is not necessary. if (!resultAlgorithm.shouldRetry(prevThrowable, prevResponse)) { return null; } TimedAttemptSettings newSettings = resultAlgorithm.createNextAttempt(prevThrowable, prevResponse, prevSettings); if (newSettings == null) { newSettings = timedAlgorithm.createNextAttempt(prevSettings); } return newSettings; }
/** * Creates a next attempt {@link TimedAttemptSettings}. This method will return first non-null * value, returned by either result or timed retry algorithms in that particular order. * * @param prevThrowable exception thrown by the previous attempt or null if a result was returned * instead * @param prevResponse response returned by the previous attempt or null if an exception was * thrown instead * @param prevSettings previous attempt settings * @return next attempt settings, can be {@code null}, if no there should be no new attempt */ public TimedAttemptSettings createNextAttempt( Throwable prevThrowable, ResponseT prevResponse, TimedAttemptSettings prevSettings) { // a small optimization, which allows to avoid calling relatively heavy methods // like timedAlgorithm.createNextAttempt(), when it is not necessary. if (!resultAlgorithm.shouldRetry(prevThrowable, prevResponse)) { return null; } TimedAttemptSettings newSettings = resultAlgorithm.createNextAttempt(prevThrowable, prevResponse, prevSettings); if (newSettings == null) { newSettings = timedAlgorithm.createNextAttempt(prevSettings); } return newSettings; }