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
This commit is contained in:
Brett Porter 2009-10-07 16:29:27 +00:00
parent eb9383c0a4
commit 8142e83c50
2 changed files with 34 additions and 10 deletions

View File

@ -49,6 +49,7 @@ import org.codehaus.plexus.spring.PlexusToSpringUtils;
import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator; import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils; 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'. // DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL' and 'REPORT'.
int methodCode = DavMethods.getMethodCode( request.getMethod() ); int methodCode = DavMethods.getMethodCode( request.getMethod() );
boolean noCache = boolean noCache =
DavMethods.isDeltaVMethod( webdavRequest ) && DavMethods.isDeltaVMethod( webdavRequest )
!( DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT == methodCode ); && !( DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT == methodCode );
WebdavResponse webdavResponse = new WebdavResponseImpl( response, noCache ); WebdavResponse webdavResponse = new WebdavResponseImpl( response, noCache );
DavResource resource = null; DavResource resource = null;
try try
{ {
// make sure there is a authenticated user // make sure there is a authenticated user
if ( !getDavSessionProvider().attachSession( webdavRequest ) ) if ( !getDavSessionProvider().attachSession( webdavRequest ) )
{ {
@ -115,7 +116,7 @@ public class RepositoryServlet
// check matching if=header for lock-token relevant operations // check matching if=header for lock-token relevant operations
resource = resource =
getResourceFactory().createResource( webdavRequest.getRequestLocator(), webdavRequest, webdavResponse ); getResourceFactory().createResource( webdavRequest.getRequestLocator(), webdavRequest, webdavResponse );
if ( !isPreconditionValid( webdavRequest, resource ) ) if ( !isPreconditionValid( webdavRequest, resource ) )
{ {
webdavResponse.sendError( DavServletResponse.SC_PRECONDITION_FAILED ); webdavResponse.sendError( DavServletResponse.SC_PRECONDITION_FAILED );
@ -154,7 +155,7 @@ public class RepositoryServlet
} }
} }
finally finally
{ {
getDavSessionProvider().releaseSession( webdavRequest ); getDavSessionProvider().releaseSession( webdavRequest );
} }
} }
@ -186,14 +187,14 @@ public class RepositoryServlet
} }
resourceFactory = resourceFactory =
(DavResourceFactory) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaDavResourceFactory.class ) ); (DavResourceFactory) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaDavResourceFactory.class ) );
locatorFactory = new ArchivaDavLocatorFactory(); locatorFactory = new ArchivaDavLocatorFactory();
ServletAuthenticator servletAuth = ServletAuthenticator servletAuth =
(ServletAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( ServletAuthenticator.class.getName() ) ); (ServletAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( ServletAuthenticator.class.getName() ) );
HttpAuthenticator httpAuth = HttpAuthenticator httpAuth =
(HttpAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( HttpAuthenticator.ROLE, "basic" ) ); (HttpAuthenticator) wac.getBean( PlexusToSpringUtils.buildSpringId( HttpAuthenticator.ROLE, "basic" ) );
sessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth ); sessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth );
} }
@ -236,7 +237,7 @@ public class RepositoryServlet
protected boolean isPreconditionValid( final WebdavRequest request, final DavResource davResource ) protected boolean isPreconditionValid( final WebdavRequest request, final DavResource davResource )
{ {
// check for read or write access to the resource when resource-based permission is implemented // check for read or write access to the resource when resource-based permission is implemented
return true; return true;
} }
@ -279,4 +280,25 @@ public class RepositoryServlet
{ {
return "Basic realm=\"Repository Archiva Managed " + repository + " Repository\""; 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();
}
} }

View File

@ -212,6 +212,8 @@ public abstract class AbstractRepositoryServletTestCase
FileUtils.deleteDirectory(repoRootInternal); FileUtils.deleteDirectory(repoRootInternal);
} }
release( archivaConfiguration );
super.tearDown(); super.tearDown();
} }