From 542ccae5022fae8f94d2024b3c51058f49fd67cc Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 1 Mar 2015 19:34:58 +0000 Subject: [PATCH] HTTPCLIENT-1621: Possible NPE/incorrect type in HttpClientBuilder#evictIdleConnections Method has been deprecated and a new one has been added with a simple type. Old method merely calls the new one now. git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1663151 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/impl/client/HttpClientBuilder.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java index ed5b22c86..d997c100b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java @@ -796,14 +796,44 @@ public class HttpClientBuilder { * @see #setConnectionManagerShared(boolean) * @see org.apache.http.conn.HttpClientConnectionManager#closeExpiredConnections() * - * @param maxIdleTime maxium time persistent connections can stay idle while kept alive + * @param maxIdleTime maximum time persistent connections can stay idle while kept alive + * in the connection pool. Connections whose inactivity period exceeds this value will + * get closed and evicted from the pool. + * @param maxIdleTimeUnit time unit for the above parameter. + * + * @deprecated (4.5) use {@link #evictIdleConnections(long, TimeUnit)} + * + * @since 4.4 + */ + @Deprecated + public final HttpClientBuilder evictIdleConnections(final Long maxIdleTime, final TimeUnit maxIdleTimeUnit) { + return evictIdleConnections(maxIdleTime.longValue(), maxIdleTimeUnit); + } + + /** + * Makes this instance of HttpClient proactively evict idle connections from the + * connection pool using a background thread. + *

+ * One MUST explicitly close HttpClient with {@link CloseableHttpClient#close()} in order + * to stop and release the background thread. + *

+ * Please note this method has no effect if the instance of HttpClient is configuted to + * use a shared connection manager. + *

+ * Please note this method may not be used when the instance of HttpClient is created + * inside an EJB container. + * + * @see #setConnectionManagerShared(boolean) + * @see org.apache.http.conn.HttpClientConnectionManager#closeExpiredConnections() + * + * @param maxIdleTime maximum time persistent connections can stay idle while kept alive * in the connection pool. Connections whose inactivity period exceeds this value will * get closed and evicted from the pool. * @param maxIdleTimeUnit time unit for the above parameter. * * @since 4.4 */ - public final HttpClientBuilder evictIdleConnections(final Long maxIdleTime, final TimeUnit maxIdleTimeUnit) { + public final HttpClientBuilder evictIdleConnections(final long maxIdleTime, final TimeUnit maxIdleTimeUnit) { this.evictIdleConnections = true; this.maxIdleTime = maxIdleTime; this.maxIdleTimeUnit = maxIdleTimeUnit;