diff --git a/src/main/java/com/firebolt/jdbc/client/config/RetryInterceptor.java b/src/main/java/com/firebolt/jdbc/client/config/RetryInterceptor.java index e01f31b28..3494adbf3 100644 --- a/src/main/java/com/firebolt/jdbc/client/config/RetryInterceptor.java +++ b/src/main/java/com/firebolt/jdbc/client/config/RetryInterceptor.java @@ -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; diff --git a/src/test/java/com/firebolt/jdbc/client/config/RetryInterceptorTest.java b/src/test/java/com/firebolt/jdbc/client/config/RetryInterceptorTest.java index 7eeb16926..f57ec2506 100644 --- a/src/test/java/com/firebolt/jdbc/client/config/RetryInterceptorTest.java +++ b/src/test/java/com/firebolt/jdbc/client/config/RetryInterceptorTest.java @@ -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