Top Description Fields Constructors Methods
org.apache.http.impl.client

public Class DefaultHttpRequestRetryHandler

extends Object
implements HttpRequestRetryHandler
Class Inheritance
All Implemented Interfaces
org.apache.http.client.HttpRequestRetryHandler
Known Direct Subclasses
org.apache.http.impl.client.StandardHttpRequestRetryHandler
Annotations
@Contract
threading:IMMUTABLE
Imports
java.io.IOException, .InterruptedIOException, java.net.ConnectException, .NoRouteToHostException, .UnknownHostException, java.util.Arrays, .Collection, .HashSet, .Set, javax.net.ssl.SSLException, org.apache.http.HttpEntityEnclosingRequest, .HttpRequest, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.client.HttpRequestRetryHandler, org.apache.http.client.methods.HttpUriRequest, org.apache.http.client.protocol.HttpClientContext, org.apache.http.protocol.HttpContext, org.apache.http.util.Args

The default HttpRequestRetryHandler used by request executors.
Since
4.0

Field Summary

Modifier and TypeField and Description
public static final DefaultHttpRequestRetryHandler
private final Set<Class<? extends IOException>>
private final boolean
requestSentRetryEnabled

Whether or not methods that have successfully sent their request will be retried

private final int
retryCount

the number of times a method will be retried

Constructor Summary

AccessConstructor and Description
protected
DefaultHttpRequestRetryHandler(final int
how many times to retry; 0 means no retries
retryCount
,
final boolean
true if it's OK to retry requests that have been sent
requestSentRetryEnabled
,
final Collection<Class<? extends IOException>>
the IOException types that should not be retried
clazzes
)

Create the request retry handler using the specified IOException classes

public
DefaultHttpRequestRetryHandler(final int
how many times to retry; 0 means no retries
retryCount
,
final boolean
true if it's OK to retry non-idempotent requests that have been sent
requestSentRetryEnabled
)

Create the request retry handler using the following list of non-retriable IOException classes:

  • InterruptedIOException
  • UnknownHostException
  • ConnectException
  • SSLException
public
DefaultHttpRequestRetryHandler()

Create the request retry handler with a retry count of 3, requestSentRetryEnabled false and using the following list of non-retriable IOException classes:

  • InterruptedIOException
  • UnknownHostException
  • ConnectException
  • SSLException

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the maximum number of times a method will be retried
getRetryCount
()

protected boolean
public boolean

Returns:

true if this handler will retry methods that have successfully sent their request, false otherwise
isRequestSentRetryEnabled
()

protected boolean
requestIsAborted(final HttpRequest request)

Deprecated (4.3)
public boolean
retryRequest(final IOException
the exception that occurred
exception
,
final int
the number of times this method has been unsuccessfully executed
executionCount
,
final HttpContext
the context for the request execution
context
)

Implements org.apache.http.client.HttpRequestRetryHandler.retryRequest.

Used retryCount and requestSentRetryEnabled to determine if the given method should be retried.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final DefaultHttpRequestRetryHandler INSTANCE
nonRetriableClassesback to summary
private final Set<Class<? extends IOException>> nonRetriableClasses
requestSentRetryEnabledback to summary
private final boolean requestSentRetryEnabled

Whether or not methods that have successfully sent their request will be retried

retryCountback to summary
private final int retryCount

the number of times a method will be retried

Constructor Detail

DefaultHttpRequestRetryHandlerback to summary
protected DefaultHttpRequestRetryHandler(final int retryCount, final boolean requestSentRetryEnabled, final Collection<Class<? extends IOException>> clazzes)

Create the request retry handler using the specified IOException classes

Parameters
retryCount:int

how many times to retry; 0 means no retries

requestSentRetryEnabled:boolean

true if it's OK to retry requests that have been sent

clazzes:Collection<Class<? extends IOException>>

the IOException types that should not be retried

Since
4.3
DefaultHttpRequestRetryHandlerback to summary
public DefaultHttpRequestRetryHandler(final int retryCount, final boolean requestSentRetryEnabled)

Create the request retry handler using the following list of non-retriable IOException classes:

  • InterruptedIOException
  • UnknownHostException
  • ConnectException
  • SSLException
Parameters
retryCount:int

how many times to retry; 0 means no retries

requestSentRetryEnabled:boolean

true if it's OK to retry non-idempotent requests that have been sent

Annotations
@SuppressWarnings:unchecked
DefaultHttpRequestRetryHandlerback to summary
public DefaultHttpRequestRetryHandler()

Create the request retry handler with a retry count of 3, requestSentRetryEnabled false and using the following list of non-retriable IOException classes:

  • InterruptedIOException
  • UnknownHostException
  • ConnectException
  • SSLException

Method Detail

getRetryCountback to summary
public int getRetryCount()
Returns:int

the maximum number of times a method will be retried

handleAsIdempotentback to summary
protected boolean handleAsIdempotent(final HttpRequest request)
Since
4.2
isRequestSentRetryEnabledback to summary
public boolean isRequestSentRetryEnabled()
Returns:boolean

true if this handler will retry methods that have successfully sent their request, false otherwise

requestIsAbortedback to summary
protected boolean requestIsAborted(final HttpRequest request)

Deprecated

(4.3)

Annotations
@Deprecated
Since
4.2
retryRequestback to summary
public boolean retryRequest(final IOException exception, final int executionCount, final HttpContext context)

Implements org.apache.http.client.HttpRequestRetryHandler.retryRequest.

Used retryCount and requestSentRetryEnabled to determine if the given method should be retried.

Parameters
exception:IOException

Doc from org.apache.http.client.HttpRequestRetryHandler.retryRequest.

the exception that occurred

executionCount:int

Doc from org.apache.http.client.HttpRequestRetryHandler.retryRequest.

the number of times this method has been unsuccessfully executed

context:HttpContext

Doc from org.apache.http.client.HttpRequestRetryHandler.retryRequest.

the context for the request execution

Returns:boolean

Doc from org.apache.http.client.HttpRequestRetryHandler.retryRequest.

true if the method should be retried, false otherwise

Annotations
@Override