41
41
import java .util .concurrent .CancellationException ;
42
42
import java .util .concurrent .ExecutionException ;
43
43
import java .util .concurrent .RejectedExecutionException ;
44
+ import java .util .logging .Level ;
45
+ import java .util .logging .Logger ;
44
46
45
47
/**
46
48
* For internal use only.
@@ -65,6 +67,8 @@ class BasicRetryingFuture<ResponseT> extends AbstractFuture<ResponseT>
65
67
private volatile ApiFuture <ResponseT > latestCompletedAttemptResult ;
66
68
private volatile ApiFuture <ResponseT > attemptResult ;
67
69
70
+ private static final Logger LOG = Logger .getLogger (BasicRetryingFuture .class .getName ());
71
+
68
72
BasicRetryingFuture (
69
73
Callable <ResponseT > callable ,
70
74
RetryAlgorithm <ResponseT > retryAlgorithm ,
@@ -166,6 +170,20 @@ void handleAttempt(Throwable throwable, ResponseT response) {
166
170
retryAlgorithm .createNextAttempt (throwable , response , attemptSettings );
167
171
boolean shouldRetry = retryAlgorithm .shouldRetry (throwable , response , nextAttemptSettings );
168
172
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
+ }
169
187
tracer .attemptFailed (throwable , nextAttemptSettings .getRandomizedRetryDelay ());
170
188
attemptSettings = nextAttemptSettings ;
171
189
setAttemptResult (throwable , response , true );
0 commit comments