private boolean shouldContinue(HttpCommand command, HttpResponse response) { boolean shouldContinue = false; if (retryHandler.shouldRetryRequest(command, response)) { shouldContinue = true; } else { errorHandler.handleError(command, response); } return shouldContinue; }
private boolean shouldContinue(HttpCommand command, HttpResponse response) { boolean shouldContinue = false; if (retryHandler.shouldRetryRequest(command, response)) { shouldContinue = true; } else { errorHandler.handleError(command, response); } return shouldContinue; }
private boolean shouldContinue(HttpCommand command, HttpResponse response) { boolean shouldContinue = false; if (retryHandler.shouldRetryRequest(command, response)) { shouldContinue = true; } else { errorHandler.handleError(command, response); } return shouldContinue; }
private boolean shouldContinue(HttpCommand command, HttpResponse response) { boolean shouldContinue = false; if (retryHandler.shouldRetryRequest(command, response)) { shouldContinue = true; } else { errorHandler.handleError(command, response); } return shouldContinue; } }
@VisibleForTesting boolean shouldContinue(HttpCommand command, HttpResponse response) { boolean shouldContinue = false; if (retryHandler.shouldRetryRequest(command, response)) { shouldContinue = true; } else { errorHandler.handleError(command, response); } // At this point we are going to send a new request or we have just handled the error, so // we should make sure that any open stream is closed. releasePayload(response); return shouldContinue; }
@VisibleForTesting boolean shouldContinue(HttpCommand command, HttpResponse response) { boolean shouldContinue = false; if (retryHandler.shouldRetryRequest(command, response)) { shouldContinue = true; } else { errorHandler.handleError(command, response); } // At this point we are going to send a new request or we have just handled the error, so // we should make sure that any open stream is closed. releasePayload(response); return shouldContinue; }
@VisibleForTesting boolean shouldContinue(HttpCommand command, HttpResponse response) { boolean shouldContinue = false; if (retryHandler.shouldRetryRequest(command, response)) { shouldContinue = true; } else { errorHandler.handleError(command, response); } // At this point we are going to send a new request or we have just handled the error, so // we should make sure that any open stream is closed. releasePayload(response); return shouldContinue; }
public void testStreamIsClosedWhenNotRetrying() throws IOException { MockInputStream in = new MockInputStream(2); // Input stream that produces 2 bytes HttpResponse response = HttpResponse.builder().payload(newInputStreamPayload(in)).build(); response.getPayload().getContentMetadata().setContentLength(1L); HttpCommand command = mockHttpCommand(); DelegatingRetryHandler retryHandler = EasyMock.createMock(DelegatingRetryHandler.class); DelegatingErrorHandler errorHandler = EasyMock.createMock(DelegatingErrorHandler.class); errorHandler.handleError(command, response); expectLastCall(); expect(retryHandler.shouldRetryRequest(command, response)).andReturn(false); replay(retryHandler, errorHandler); // Verify the stream is open. This consumes one byte. assertEquals(response.getPayload().openStream().available(), 2); assertEquals(response.getPayload().openStream().read(), 1); BaseHttpCommandExecutorService<?> service = mockHttpCommandExecutorService(retryHandler, errorHandler); assertFalse(service.shouldContinue(command, response)); verify(retryHandler, errorHandler); // Verify that the response stream is closed assertFalse(in.isOpen); assertTrue(response.getPayload().openStream() == in); assertEquals(response.getPayload().openStream().available(), 0); assertEquals(response.getPayload().openStream().read(), -1); }
DelegatingErrorHandler errorHandler = EasyMock.createMock(DelegatingErrorHandler.class); errorHandler.handleError(command, response); expectLastCall().andAnswer(new IAnswer<Void>() { @Override
DelegatingErrorHandler errorHandler = EasyMock.createMock(DelegatingErrorHandler.class); errorHandler.handleError(command, response); expectLastCall().andAnswer(new IAnswer<Void>() { @Override