[utilities COMMIT] /java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuild...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Sep 11 10:55:59 EDT 2015
Author: tzeller
Date: Fri Sep 11 10:55:59 2015
New Revision: 824
URL: http://svn.shibboleth.net/view/utilities?rev=824&view=rev
Log:
Add service unavailable retry strategy property.
Modified:
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java
Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java?rev=824&r1=823&r2=824&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java Fri Sep 11 10:55:59 2015
@@ -32,6 +32,7 @@
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.HttpRequestRetryHandler;
+import org.apache.http.client.ServiceUnavailableRetryStrategy;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.config.ConnectionConfig;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
@@ -182,9 +183,12 @@
/** Character set used for HTTP entity content. Default value: UTF-8 */
@Nullable private String httpContentCharSet;
-
- /** Handler which determines if a request should be retried. */
+
+ /** Handler which determines if a request should be retried after a recoverable exception during execution. */
@Nullable private HttpRequestRetryHandler retryHandler;
+
+ /** Strategy which determines if a request should be retried given the response from the target server. */
+ @Nullable private ServiceUnavailableRetryStrategy serviceUnavailStrategy;
/** The Apache HttpClientBuilder 4.3+ instance over which to layer this builder. */
private org.apache.http.impl.client.HttpClientBuilder apacheBuilder;
@@ -522,23 +526,41 @@
public void setUserAgent(@Nullable final String what) {
userAgent = what;
}
-
- /**
- * Get the handler which determines if a request should be retried.
+
+ /**
+ * Get the handler which determines if a request should be retried after a recoverable exception during execution.
*
* @return handler which determines if a request should be retried
*/
@Nullable public HttpRequestRetryHandler getHttpRequestRetryHandler() {
return retryHandler;
}
-
- /**
- * Set the handler which determines if a request should be retried.
+
+ /**
+ * Set the handler which determines if a request should be retried after a recoverable exception during execution.
*
* @param handler handler which determines if a request should be retried
*/
public void setHttpRequestRetryHandler(@Nullable final HttpRequestRetryHandler handler) {
retryHandler = handler;
+ }
+
+ /**
+ * Get the handler which determines if a request should be retried given the response from the target server.
+ *
+ * @return handler which determines if a request should be retried
+ */
+ @Nullable public ServiceUnavailableRetryStrategy getServiceUnavailableRetryHandler() {
+ return serviceUnavailStrategy;
+ }
+
+ /**
+ * Set the strategy which determines if a request should be retried given the response from the target server.
+ *
+ * @param strategy handler which determines if a request should be retried
+ */
+ public void setServiceUnavailableRetryHandler(@Nullable final ServiceUnavailableRetryStrategy strategy) {
+ serviceUnavailStrategy = strategy;
}
/**
@@ -578,6 +600,10 @@
if (retryHandler != null) {
builder.setRetryHandler(retryHandler);
}
+
+ if (serviceUnavailStrategy != null) {
+ builder.setServiceUnavailableRetryStrategy(serviceUnavailStrategy);
+ }
// RequestConfig params
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
More information about the commits
mailing list