maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From micha...@apache.org
Subject [maven-wagon] 01/01: [WAGON-531] Add default TTL for HTTP connections
Date Fri, 31 Aug 2018 20:42:28 GMT
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch WAGON-531
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git

commit dacbe208d0ea72e84597f26cb0157ac90640db96
Author: Michael Osipov <michaelo@apache.org>
AuthorDate: Fri Aug 31 22:41:57 2018 +0200

    [WAGON-531] Add default TTL for HTTP connections
---
 .../maven/wagon/shared/http/AbstractHttpClientWagon.java     | 12 +++++++++++-
 .../apache/maven/wagon/providers/webdav/WebDavWagonTest.java |  1 -
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
index 0f85d60..9f294f7 100755
--- a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
+++ b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
@@ -294,6 +294,15 @@ public abstract class AbstractHttpClientWagon
     private static final int MAX_BACKOFF_WAIT_SECONDS =
         Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxBackoffSeconds",
"180" ) );
 
+    /**
+     * Time to live in seconds for an HTTP connection. After that time, the connection will
be dropped.
+     * Intermediates tend to drop connections after some idle period. Set to -1 to maintain
connections
+     * indefinitely. This value defaults to 300 seconds.
+     *
+     * @since 3.2
+     */
+    private static final long CONN_TTL =
+        Long.getLong( "maven.wagon.httpconnectionManager.ttlSeconds", 300L );
 
     protected int backoff( int wait, String url )
         throws InterruptedException, TransferFailedException
@@ -347,7 +356,8 @@ public abstract class AbstractHttpClientWagon
                                                                                         
                        PlainConnectionSocketFactory.INSTANCE ).register(
             "https", sslConnectionSocketFactory ).build();
 
-        PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(
registry );
+        PoolingHttpClientConnectionManager connManager =
+            new PoolingHttpClientConnectionManager( registry, null, null, null, CONN_TTL,
TimeUnit.SECONDS );
         if ( persistentPool )
         {
             connManager.setDefaultMaxPerRoute( MAX_CONN_PER_ROUTE );
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
index e432970..bbe2807 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
@@ -18,7 +18,6 @@ package org.apache.maven.wagon.providers.webdav;
 import it.could.webdav.DAVServlet;
 import org.apache.http.HttpException;
 import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.StreamingWagon;


Mime
View raw message