]> source.dussan.org Git - archiva.git/commitdiff
correctly shutdown http connection manager
authorOlivier Lamy <olamy@apache.org>
Mon, 28 Jan 2013 23:29:09 +0000 (23:29 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 28 Jan 2013 23:29:09 +0000 (23:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1439693 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java

index 8a27c031ddf9ff4eaf098ab0dfbf74332a905a49..d15644f6363596ff7a71962a4ef1d27d1646fa31 100644 (file)
@@ -33,12 +33,14 @@ import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.UserInterfaceOptions;
 import org.apache.archiva.configuration.WebappConfiguration;
 import org.apache.commons.lang.StringUtils;
+import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.maven.wagon.providers.http.HttpWagon;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -52,6 +54,8 @@ public class DefaultArchivaAdministration
     implements ArchivaAdministration
 {
 
+    private PoolingClientConnectionManager poolingClientConnectionManager;
+
     @PostConstruct
     public void initialize()
         throws RepositoryAdminException
@@ -61,6 +65,15 @@ public class DefaultArchivaAdministration
         setupWagon( networkConfiguration );
     }
 
+    @PreDestroy
+    public void shutdown()
+    {
+        if ( this.poolingClientConnectionManager != null )
+        {
+            this.poolingClientConnectionManager.shutdown();
+        }
+    }
+
 
     public List<LegacyArtifactPath> getLegacyArtifactPaths()
         throws RepositoryAdminException
@@ -381,7 +394,7 @@ public class DefaultArchivaAdministration
         {
             // back to default values
             HttpWagon.setUseClientManagerPooled( true );
-            PoolingClientConnectionManager poolingClientConnectionManager = new PoolingClientConnectionManager();
+            poolingClientConnectionManager = new PoolingClientConnectionManager();
             poolingClientConnectionManager.setDefaultMaxPerRoute( 30 );
             poolingClientConnectionManager.setMaxTotal( 30 );
             HttpWagon.setConnectionManagerPooled( poolingClientConnectionManager );
@@ -390,7 +403,7 @@ public class DefaultArchivaAdministration
         else
         {
             HttpWagon.setUseClientManagerPooled( networkConfiguration.isUsePooling() );
-            PoolingClientConnectionManager poolingClientConnectionManager = new PoolingClientConnectionManager();
+            poolingClientConnectionManager = new PoolingClientConnectionManager();
             poolingClientConnectionManager.setDefaultMaxPerRoute( networkConfiguration.getMaxTotalPerHost() );
             poolingClientConnectionManager.setMaxTotal( networkConfiguration.getMaxTotal() );
             HttpWagon.setConnectionManagerPooled( poolingClientConnectionManager );