Skip to content

Commit

Permalink
Bugfix/fix retry policy (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
aymeric-dispa authored Nov 3, 2022
1 parent 6be54fb commit c519dc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public Response intercept(@NotNull Chain chain) throws IOException {
log.warn("Failure #{} - Response code: {}. Retrying to send the request.",
tryCount, response.code());
// retry the request
response = chain.call().clone().execute();
response.close();
response = chain.proceed(request);
}

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ void shouldRetryOnRetryableResponseCode(int arg) throws IOException {
Interceptor.Chain chain = mock(Interceptor.Chain.class);
Response response = mock(Response.class);
Call call = mock(Call.class);
Request request = mock(Request.class);

when(chain.request()).thenReturn(mock(Request.class));
when(chain.request()).thenReturn(request);
when(chain.proceed(any(Request.class))).thenReturn(response);
when(response.isSuccessful()).thenReturn(false);
when(response.code()).thenReturn(arg);
when(chain.call()).thenReturn(call);
when(call.clone()).thenReturn(call);
when(call.execute()).thenReturn(response);

retryInterceptor.intercept(chain);
verify(call, times(retries)).execute();
verify(chain, times(1 + retries)).proceed(request);
}

@Test
Expand Down

0 comments on commit c519dc5

Please sign in to comment.