protected static void scheduleNextRetry ( ClientRequestContext ctx , Consumer < ? super Throwable > actionOnException , Runnable retryTask , long nextDelayMillis ) { try { if ( nextDelayMillis == 0 ) { ctx . contextAwareEventLoop ( ) . execute ( retryTask ) ; } else { @ SuppressWarnings ( "unchecked" ) final ScheduledFuture < Void > scheduledFuture = ( ScheduledFuture < Void > ) ctx . contextAwareEventLoop ( ) . schedule ( retryTask , nextDelayMillis , TimeUnit . MILLISECONDS ) ; scheduledFuture . addListener ( future -> { if ( future . isCancelled ( ) ) { // future is cancelled when the client factory is closed. actionOnException . accept ( new IllegalStateException ( ClientFactory . class . getSimpleName ( ) + " has been closed." ) ) ; } } ) ; } } catch ( Throwable t ) { actionOnException . accept ( t ) ; } }
Schedules next retry .