HTTPCLIENT-1730: added #setValidateAfterInactivity to HttpClientBuilder

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1736237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2016-03-22 19:28:09 +00:00
parent 055030c9f2
commit 66c5016394
1 changed files with 19 additions and 0 deletions

View File

@ -213,6 +213,7 @@ public class HttpClientBuilder {
private long connTimeToLive = -1;
private TimeUnit connTimeToLiveTimeUnit = TimeUnit.MILLISECONDS;
private int validateAfterInactivity = 2000;
private List<Closeable> closeables;
@ -352,6 +353,23 @@ public class HttpClientBuilder {
return this;
}
/**
* Sets period after inactivity in milliseconds after which persistent
* connections must be checked to ensure they are still valid.
* <p>
* Please note this value can be overridden by the {@link #setConnectionManager(
*HttpClientConnectionManager)} method.
* </p>
*
* @see org.apache.hc.core5.http.io.HttpClientConnection#isStale()
*
* @since 5.0
*/
public final HttpClientBuilder setValidateAfterInactivity(final int validateAfterInactivity) {
this.validateAfterInactivity = validateAfterInactivity;
return this;
}
/**
* Assigns {@link HttpClientConnectionManager} instance.
*/
@ -923,6 +941,7 @@ public class HttpClientBuilder {
dnsResolver,
connTimeToLive,
connTimeToLiveTimeUnit != null ? connTimeToLiveTimeUnit : TimeUnit.MILLISECONDS);
poolingmgr.setValidateAfterInactivity(this.validateAfterInactivity);
if (defaultSocketConfig != null) {
poolingmgr.setDefaultSocketConfig(defaultSocketConfig);
}