summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2009-10-07 16:29:27 +0000
committerBrett Porter <brett@apache.org>2009-10-07 16:29:27 +0000
commit8142e83c50ee8d36b30ed832a309c587d65057dc (patch)
treea8c13bd13c7c3802ae22d2cf87d20b8d6d7506cf
parenteb9383c0a4e47ad8014e2f3af9b1e8e1aedd9170 (diff)
downloadarchiva-8142e83c50ee8d36b30ed832a309c587d65057dc.tar.gz
archiva-8142e83c50ee8d36b30ed832a309c587d65057dc.zip
additional clean up code to prevent the tests from running out of memory
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@822794 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java42
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java2
2 files changed, 34 insertions, 10 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java
index b30d8e299..156201bcf 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java
@@ -49,6 +49,7 @@ import org.codehaus.plexus.spring.PlexusToSpringUtils;
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 @@ public class RepositoryServlet
// 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 @@ public class RepositoryServlet
// 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 @@ public class RepositoryServlet
}
}
finally
- {
+ {
getDavSessionProvider().releaseSession( webdavRequest );
}
}
@@ -186,14 +187,14 @@ public class RepositoryServlet
}
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 @@ public class RepositoryServlet
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 @@ public class RepositoryServlet
{
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();
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
index 190855ffa..892eeeedb 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java
@@ -212,6 +212,8 @@ public abstract class AbstractRepositoryServletTestCase
FileUtils.deleteDirectory(repoRootInternal);
}
+ release( archivaConfiguration );
+
super.tearDown();
}