4141import java .util .concurrent .CancellationException ;
4242import java .util .concurrent .ExecutionException ;
4343import java .util .concurrent .RejectedExecutionException ;
44+ import java .util .logging .Level ;
45+ import java .util .logging .Logger ;
4446
4547/**
4648 * For internal use only.
@@ -65,6 +67,8 @@ class BasicRetryingFuture<ResponseT> extends AbstractFuture<ResponseT>
6567 private volatile ApiFuture <ResponseT > latestCompletedAttemptResult ;
6668 private volatile ApiFuture <ResponseT > attemptResult ;
6769
70+ private static final Logger LOG = Logger .getLogger (BasicRetryingFuture .class .getName ());
71+
6872 BasicRetryingFuture (
6973 Callable <ResponseT > callable ,
7074 RetryAlgorithm <ResponseT > retryAlgorithm ,
@@ -166,6 +170,20 @@ void handleAttempt(Throwable throwable, ResponseT response) {
166170 retryAlgorithm .createNextAttempt (throwable , response , attemptSettings );
167171 boolean shouldRetry = retryAlgorithm .shouldRetry (throwable , response , nextAttemptSettings );
168172 if (shouldRetry ) {
173+ // Log retry info
174+ if (LOG .isLoggable (Level .FINEST )) {
175+ LOG .log (
176+ Level .FINEST ,
177+ "Retrying with:\n {0}\n {1}\n {2}\n {3}" ,
178+ new Object [] {
179+ "enclosingMethod: " + callable .getClass ().getEnclosingMethod () != null
180+ ? callable .getClass ().getEnclosingMethod ().getName ()
181+ : "" ,
182+ "attemptCount: " + attemptSettings .getAttemptCount (),
183+ "delay: " + attemptSettings .getRetryDelay (),
184+ "retriableException: " + throwable
185+ });
186+ }
169187 tracer .attemptFailed (throwable , nextAttemptSettings .getRandomizedRetryDelay ());
170188 attemptSettings = nextAttemptSettings ;
171189 setAttemptResult (throwable , response , true );
0 commit comments