archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r822794 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src: main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
Date Wed, 07 Oct 2009 16:29:28 GMT
Author: brett
Date: Wed Oct  7 16:29:27 2009
New Revision: 822794

URL: http://svn.apache.org/viewvc?rev=822794&view=rev
Log:
additional clean up code to prevent the tests from running out of memory

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java?rev=822794&r1=822793&r2=822794&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java
Wed Oct  7 16:29:27 2009
@@ -49,6 +49,7 @@
 import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 
@@ -99,13 +100,13 @@
         // DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL'
and 'REPORT'.
         int methodCode = DavMethods.getMethodCode( request.getMethod() );
         boolean noCache =
-            DavMethods.isDeltaVMethod( webdavRequest ) &&
-                !( DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT
== methodCode );
+            DavMethods.isDeltaVMethod( webdavRequest )
+                && !( DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT
== methodCode );
         WebdavResponse webdavResponse = new WebdavResponseImpl( response, noCache );
         DavResource resource = null;
-        
+
         try
-        {   
+        {
             // make sure there is a authenticated user
             if ( !getDavSessionProvider().attachSession( webdavRequest ) )
             {
@@ -115,7 +116,7 @@
             // check matching if=header for lock-token relevant operations
             resource =
                 getResourceFactory().createResource( webdavRequest.getRequestLocator(), webdavRequest,
webdavResponse );
-            
+
             if ( !isPreconditionValid( webdavRequest, resource ) )
             {
                 webdavResponse.sendError( DavServletResponse.SC_PRECONDITION_FAILED );
@@ -154,7 +155,7 @@
             }
         }
         finally
-        {  
+        {
             getDavSessionProvider().releaseSession( webdavRequest );
         }
     }
@@ -186,14 +187,14 @@
         }
 
         resourceFactory =
-            (DavResourceFactory) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaDavResourceFactory.class
) );        
+            (DavResourceFactory) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaDavResourceFactory.class
) );
         locatorFactory = new ArchivaDavLocatorFactory();
-        
+
         ServletAuthenticator servletAuth =
             (ServletAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( ServletAuthenticator.class.getName()
) );
         HttpAuthenticator httpAuth =
             (HttpAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( HttpAuthenticator.ROLE,
"basic" ) );
-        
+
         sessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth );
     }
 
@@ -236,7 +237,7 @@
     protected boolean isPreconditionValid( final WebdavRequest request, final DavResource
davResource )
     {
         // check for read or write access to the resource when resource-based permission
is implemented
-        
+
         return true;
     }
 
@@ -279,4 +280,25 @@
     {
         return "Basic realm=\"Repository Archiva Managed " + repository + " Repository\"";
     }
+
+    @Override
+    public void destroy()
+    {
+        configuration.removeListener( this );
+        
+        resourceFactory = null;
+        configuration = null;
+        locatorFactory = null;
+        sessionProvider = null;
+        repositoryMap.clear();
+        repositoryMap = null;
+        
+        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(
getServletContext() );
+
+        if ( wac instanceof ConfigurableApplicationContext )
+        {
+            ( (ConfigurableApplicationContext) wac ).close();
+        }
+        super.destroy();
+    }
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java?rev=822794&r1=822793&r2=822794&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
Wed Oct  7 16:29:27 2009
@@ -212,6 +212,8 @@
             FileUtils.deleteDirectory(repoRootInternal);
         }
         
+        release( archivaConfiguration );
+        
         super.tearDown();
     }
 



Mime
View raw message