mirror of https://github.com/apache/jclouds.git
Retry on S3 HTTP 504 Gateway Timeout status codes
RiakCS using the S3 interface occasionally surfaces these status codes.
This commit is contained in:
parent
33f244dbab
commit
a7fa3b9c62
|
@ -50,7 +50,8 @@ public class AWSServerErrorRetryHandler extends BackoffLimitedRetryHandler {
|
|||
|
||||
@Override
|
||||
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
|
||||
if (response.getStatusCode() == 503) {
|
||||
switch (response.getStatusCode()) {
|
||||
case 503: // Service Unavailable
|
||||
// Content can be null in the case of HEAD requests
|
||||
if (response.getPayload() != null) {
|
||||
closeClientButKeepContentStream(response);
|
||||
|
@ -59,6 +60,9 @@ public class AWSServerErrorRetryHandler extends BackoffLimitedRetryHandler {
|
|||
return shouldRetryRequestOnError(command, response, error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 504: // Gateway Timeout
|
||||
return super.shouldRetryRequest(command, response);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.easymock.EasyMock.expect;
|
|||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -112,4 +113,21 @@ public class AWSServerErrorRetryHandlerTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test504DoesRetry() {
|
||||
AWSUtils utils = createMock(AWSUtils.class);
|
||||
HttpCommand command = createMock(HttpCommand.class);
|
||||
expect(command.getFailureCount()).andReturn(1).anyTimes();
|
||||
expect(command.incrementFailureCount()).andReturn(1);
|
||||
expect(command.isReplayable()).andReturn(true);
|
||||
|
||||
replay(utils, command);
|
||||
|
||||
AWSServerErrorRetryHandler retry = new AWSServerErrorRetryHandler(utils,
|
||||
ImmutableSet.<String> of());
|
||||
|
||||
assertTrue(retry.shouldRetryRequest(command, HttpResponse.builder().statusCode(504).build()));
|
||||
|
||||
verify(utils, command);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue