improve svnkit memory consumption

This commit is contained in:
Sebastian Sdorra
2012-05-19 12:28:35 +02:00
parent b19014d756
commit 82b880a479
7 changed files with 61 additions and 46 deletions

View File

@@ -130,6 +130,10 @@ public class SvnBlameViewer implements BlameViewer
{
logger.error("could not create blame view", ex);
}
finally
{
SvnUtil.closeSession(svnRepository);
}
return new BlameResult(blameLines.size(), blameLines);
}

View File

@@ -125,7 +125,7 @@ public class SvnChangesetViewer implements ChangesetViewer
catch (SVNException ex) {}
finally
{
close(repository);
SvnUtil.closeSession(repository);
}
return changeset;
@@ -182,7 +182,7 @@ public class SvnChangesetViewer implements ChangesetViewer
}
finally
{
close(repository);
SvnUtil.closeSession(repository);
}
return changesets;
@@ -268,7 +268,7 @@ public class SvnChangesetViewer implements ChangesetViewer
}
finally
{
close(repository);
SvnUtil.closeSession(repository);
}
return changesets;
@@ -276,20 +276,6 @@ public class SvnChangesetViewer implements ChangesetViewer
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param repository
*/
private void close(SVNRepository repository)
{
if (repository != null)
{
repository.closeSession();
}
}
/**
* Method description
*

View File

@@ -111,6 +111,8 @@ public class SvnDiffViewer implements DiffViewer
AssertUtil.assertIsNotEmpty(revision);
AssertUtil.assertIsNotNull(output);
SVNClientManager clientManager = null;
try
{
SVNURL svnurl = SVNURL.fromFile(directory);
@@ -120,7 +122,7 @@ public class SvnDiffViewer implements DiffViewer
svnurl = svnurl.appendPath(path, true);
}
SVNClientManager clientManager = SVNClientManager.newInstance();
clientManager = SVNClientManager.newInstance();
SVNDiffClient diffClient = clientManager.getDiffClient();
ISVNDiffGenerator diffGenerator = diffClient.getDiffGenerator();
@@ -143,6 +145,8 @@ public class SvnDiffViewer implements DiffViewer
catch (Exception ex)
{
logger.error("could not create blame view", ex);
} finally {
SvnUtil.dispose(clientManager);
}
}

View File

@@ -148,7 +148,7 @@ public class SvnPostReceiveHookEvent extends AbstractRepositoryHookEvent
}
finally
{
repository.closeSession();
SvnUtil.closeSession(repository);
}
return result;

View File

@@ -120,11 +120,14 @@ public class SvnPreReceiveHookEvent extends AbstractRepositoryHookEvent
private Collection<Changeset> fetchChangesets()
{
List<Changeset> csets = new ArrayList<Changeset>();
SVNClientManager cm = null;
try
{
ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
SVNClientManager cm = SVNClientManager.newInstance(options);
cm = SVNClientManager.newInstance(options);
SVNLookClient clientManager = cm.getLookClient();
SVNLogEntry entry = clientManager.doGetInfo(repositoryDirectory,
transaction);
@@ -148,6 +151,10 @@ public class SvnPreReceiveHookEvent extends AbstractRepositoryHookEvent
"could not fetch changesets for transaction ".concat(transaction),
ex);
}
finally
{
SvnUtil.dispose(cm);
}
return csets;
}

View File

@@ -118,7 +118,7 @@ public class SvnRepositoryBrowser implements RepositoryBrowser
}
finally
{
close(svnRepository);
SvnUtil.closeSession(svnRepository);
}
}
@@ -186,7 +186,7 @@ public class SvnRepositoryBrowser implements RepositoryBrowser
}
finally
{
close(svnRepository);
SvnUtil.closeSession(svnRepository);
}
return result;
@@ -194,20 +194,6 @@ public class SvnRepositoryBrowser implements RepositoryBrowser
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param svnRepository
*/
private void close(SVNRepository svnRepository)
{
if (svnRepository != null)
{
svnRepository.closeSession();
}
}
/**
* Method description
*

View File

@@ -35,9 +35,13 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tmatesoft.svn.core.SVNLogEntry;
import org.tmatesoft.svn.core.SVNLogEntryPath;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.admin.SVNChangeEntry;
import sonia.scm.util.Util;
@@ -45,8 +49,6 @@ import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
@@ -55,6 +57,13 @@ import org.slf4j.LoggerFactory;
public class SvnUtil
{
/**
* the logger for SvnUtil
*/
private static final Logger logger = LoggerFactory.getLogger(SvnUtil.class);
//~--- methods --------------------------------------------------------------
/**
* TODO: type replaced
*
@@ -121,18 +130,16 @@ public class SvnUtil
{
if (repository != null)
{
try {
repository.closeSession();
} catch (Exception ex){
try
{
repository.closeSession();
}
catch (Exception ex)
{
logger.error("could not close svn repository session");
}
}
}
/**
* the logger for SvnUtil
*/
private static final Logger logger = LoggerFactory.getLogger(SvnUtil.class);
/**
* Method description
@@ -170,4 +177,25 @@ public class SvnUtil
return changeset;
}
/**
* Method description
*
*
* @param clientManager
*/
public static void dispose(SVNClientManager clientManager)
{
if (clientManager != null)
{
try
{
clientManager.dispose();
}
catch (Exception ex)
{
logger.error("could not dispose clientmanager", ex);
}
}
}
}