I'm doing this:
httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(2,
true));
...
return httpClient.execute(new HttpGet(url), jsonResponseHandler, new
BasicHttpContext());
...but when the server returns "503 Service Unavailable" I don't believe the
retry handler is getting invoked. My response handler looks like:
private static final class JsonResponseHandler implements
ResponseHandler<Map> {
public Map handleResponse(HttpResponse httpResponse) throws
java.io.IOException {
HttpEntity httpEntity = httpResponse.getEntity();
try {
StatusLine statusLine = httpResponse.getStatusLine();
switch (statusLine.getStatusCode()) {
case 200: // Should be a valid JSON response
return (Map)JSONValue.parseWithException(new
InputStreamReader(httpEntity.getContent()));
case 503:
default:
throw new
HttpResponseException(statusLine.getStatusCode(), statusLine.toString());
}
...
I'm not 100% sure if throwing that HttpResponseException is causing the
retry to get invoked, but I don't think it is. Is there anything else I
should be doing in that "case 503:" that would induce a retry automatically?
Or do I need to wrap my own retry logic around the httpClient.execute call?
I'm sure I'm missing something simple.
Dan