mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 19:45:51 +01:00
improve svnkit memory consumption
This commit is contained in:
@@ -130,6 +130,10 @@ public class SvnBlameViewer implements BlameViewer
|
|||||||
{
|
{
|
||||||
logger.error("could not create blame view", ex);
|
logger.error("could not create blame view", ex);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SvnUtil.closeSession(svnRepository);
|
||||||
|
}
|
||||||
|
|
||||||
return new BlameResult(blameLines.size(), blameLines);
|
return new BlameResult(blameLines.size(), blameLines);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
catch (SVNException ex) {}
|
catch (SVNException ex) {}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
close(repository);
|
SvnUtil.closeSession(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
return changeset;
|
return changeset;
|
||||||
@@ -182,7 +182,7 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
close(repository);
|
SvnUtil.closeSession(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
return changesets;
|
return changesets;
|
||||||
@@ -268,7 +268,7 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
close(repository);
|
SvnUtil.closeSession(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
return changesets;
|
return changesets;
|
||||||
@@ -276,20 +276,6 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
*/
|
|
||||||
private void close(SVNRepository repository)
|
|
||||||
{
|
|
||||||
if (repository != null)
|
|
||||||
{
|
|
||||||
repository.closeSession();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ public class SvnDiffViewer implements DiffViewer
|
|||||||
AssertUtil.assertIsNotEmpty(revision);
|
AssertUtil.assertIsNotEmpty(revision);
|
||||||
AssertUtil.assertIsNotNull(output);
|
AssertUtil.assertIsNotNull(output);
|
||||||
|
|
||||||
|
SVNClientManager clientManager = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SVNURL svnurl = SVNURL.fromFile(directory);
|
SVNURL svnurl = SVNURL.fromFile(directory);
|
||||||
@@ -120,7 +122,7 @@ public class SvnDiffViewer implements DiffViewer
|
|||||||
svnurl = svnurl.appendPath(path, true);
|
svnurl = svnurl.appendPath(path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVNClientManager clientManager = SVNClientManager.newInstance();
|
clientManager = SVNClientManager.newInstance();
|
||||||
SVNDiffClient diffClient = clientManager.getDiffClient();
|
SVNDiffClient diffClient = clientManager.getDiffClient();
|
||||||
ISVNDiffGenerator diffGenerator = diffClient.getDiffGenerator();
|
ISVNDiffGenerator diffGenerator = diffClient.getDiffGenerator();
|
||||||
|
|
||||||
@@ -143,6 +145,8 @@ public class SvnDiffViewer implements DiffViewer
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.error("could not create blame view", ex);
|
logger.error("could not create blame view", ex);
|
||||||
|
} finally {
|
||||||
|
SvnUtil.dispose(clientManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class SvnPostReceiveHookEvent extends AbstractRepositoryHookEvent
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
repository.closeSession();
|
SvnUtil.closeSession(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -120,11 +120,14 @@ public class SvnPreReceiveHookEvent extends AbstractRepositoryHookEvent
|
|||||||
private Collection<Changeset> fetchChangesets()
|
private Collection<Changeset> fetchChangesets()
|
||||||
{
|
{
|
||||||
List<Changeset> csets = new ArrayList<Changeset>();
|
List<Changeset> csets = new ArrayList<Changeset>();
|
||||||
|
SVNClientManager cm = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
|
ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
|
||||||
SVNClientManager cm = SVNClientManager.newInstance(options);
|
|
||||||
|
cm = SVNClientManager.newInstance(options);
|
||||||
|
|
||||||
SVNLookClient clientManager = cm.getLookClient();
|
SVNLookClient clientManager = cm.getLookClient();
|
||||||
SVNLogEntry entry = clientManager.doGetInfo(repositoryDirectory,
|
SVNLogEntry entry = clientManager.doGetInfo(repositoryDirectory,
|
||||||
transaction);
|
transaction);
|
||||||
@@ -148,6 +151,10 @@ public class SvnPreReceiveHookEvent extends AbstractRepositoryHookEvent
|
|||||||
"could not fetch changesets for transaction ".concat(transaction),
|
"could not fetch changesets for transaction ".concat(transaction),
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SvnUtil.dispose(cm);
|
||||||
|
}
|
||||||
|
|
||||||
return csets;
|
return csets;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class SvnRepositoryBrowser implements RepositoryBrowser
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
close(svnRepository);
|
SvnUtil.closeSession(svnRepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ public class SvnRepositoryBrowser implements RepositoryBrowser
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
close(svnRepository);
|
SvnUtil.closeSession(svnRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -194,20 +194,6 @@ public class SvnRepositoryBrowser implements RepositoryBrowser
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param svnRepository
|
|
||||||
*/
|
|
||||||
private void close(SVNRepository svnRepository)
|
|
||||||
{
|
|
||||||
if (svnRepository != null)
|
|
||||||
{
|
|
||||||
svnRepository.closeSession();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -35,9 +35,13 @@ package sonia.scm.repository;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.tmatesoft.svn.core.SVNLogEntry;
|
import org.tmatesoft.svn.core.SVNLogEntry;
|
||||||
import org.tmatesoft.svn.core.SVNLogEntryPath;
|
import org.tmatesoft.svn.core.SVNLogEntryPath;
|
||||||
import org.tmatesoft.svn.core.io.SVNRepository;
|
import org.tmatesoft.svn.core.io.SVNRepository;
|
||||||
|
import org.tmatesoft.svn.core.wc.SVNClientManager;
|
||||||
import org.tmatesoft.svn.core.wc.admin.SVNChangeEntry;
|
import org.tmatesoft.svn.core.wc.admin.SVNChangeEntry;
|
||||||
|
|
||||||
import sonia.scm.util.Util;
|
import sonia.scm.util.Util;
|
||||||
@@ -45,8 +49,6 @@ import sonia.scm.util.Util;
|
|||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -55,6 +57,13 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class SvnUtil
|
public class SvnUtil
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the logger for SvnUtil
|
||||||
|
*/
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SvnUtil.class);
|
||||||
|
|
||||||
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: type replaced
|
* TODO: type replaced
|
||||||
*
|
*
|
||||||
@@ -121,19 +130,17 @@ public class SvnUtil
|
|||||||
{
|
{
|
||||||
if (repository != null)
|
if (repository != null)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
repository.closeSession();
|
repository.closeSession();
|
||||||
} catch (Exception ex){
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
logger.error("could not close svn repository session");
|
logger.error("could not close svn repository session");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* the logger for SvnUtil
|
|
||||||
*/
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SvnUtil.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -170,4 +177,25 @@ public class SvnUtil
|
|||||||
|
|
||||||
return changeset;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user