IDEA-56714 IDEA 9.0.3 EAP builds (including 413) generate extensive amount of simultaneous SVN sessions/connections and don't close them

This commit is contained in:
irengrig
2010-07-29 16:18:00 +04:00
parent da0aec126e
commit 5d2a334237
8 changed files with 84 additions and 18 deletions
@@ -616,11 +616,17 @@ public class SvnUtil {
}
public static boolean doesRepositorySupportMergeinfo(final SvnVcs vcs, final SVNURL url) {
SVNRepository repository = null;
try {
return vcs.createRepository(url).hasCapability(SVNCapability.MERGE_INFO);
repository = vcs.createRepository(url);
return repository.hasCapability(SVNCapability.MERGE_INFO);
}
catch (SVNException e) {
return false;
} finally {
if (repository != null) {
repository.closeSession();
}
}
}
}
@@ -133,6 +133,8 @@ public class CompareWithBranchAction extends AnAction implements DumbAware {
SVNWCAccess wcAccess = vcs.createWCAccess();
SVNRepository repository = null;
SVNRepository repository2 = null;
try {
SVNAdminAreaInfo info = wcAccess.openAnchor(new File(myVirtualFile.getPath()), false, SVNWCAccess.INFINITE_DEPTH);
File anchorPath = info.getAnchor().getRoot();
@@ -150,18 +152,25 @@ public class CompareWithBranchAction extends AnAction implements DumbAware {
}
SVNURL anchorURL = anchorEntry.getSVNURL();
SVNRepository repository = vcs.createRepository(anchorURL.toString());
repository = vcs.createRepository(anchorURL.toString());
SVNReporter reporter = new SVNReporter(info, info.getAnchor().getFile(info.getTargetName()), false, true, SVNDepth.INFINITY,
false, false, true, SVNDebugLog.getDefaultLog());
long rev = repository.getLatestRevision();
repository2 = vcs.createRepository((target == null) ? url.toString() : url.removePathTail().toString());
SvnDiffEditor diffEditor = new SvnDiffEditor((target == null) ? myVirtualFile : myVirtualFile.getParent(),
vcs.createRepository((target == null) ? url.toString() : url.removePathTail().toString()), rev, true);
repository2, rev, true);
repository.diff(url, rev, rev, target, true, true, false, reporter,
SVNCancellableEditor.newInstance(diffEditor, new SvnProgressCanceller(), null));
changes.addAll(diffEditor.getChangesMap().values());
}
finally {
wcAccess.close();
if (repository != null) {
repository.closeSession();
}
if (repository2 != null) {
repository2.closeSession();
}
}
}
catch(SVNCancelException ex) {
@@ -27,6 +27,7 @@ import org.jetbrains.idea.svn.SvnConfiguration;
import org.jetbrains.idea.svn.SvnServerFileManager;
import org.jetbrains.idea.svn.SvnVcs;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.io.SVNRepository;
import javax.swing.*;
import java.awt.*;
@@ -137,10 +138,16 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati
if (pi != null) {
pi.setText("Connecting to " + url);
}
SVNRepository repository = null;
try {
SvnVcs.getInstance(myProject).createRepository(url).testConnection();
repository = SvnVcs.getInstance(myProject).createRepository(url);
repository.testConnection();
} catch (SVNException exc) {
excRef.set(exc);
} finally {
if (repository != null) {
repository.closeSession();
}
}
}
}, "Test connection", true, myProject);
@@ -23,6 +23,7 @@ import org.jetbrains.idea.svn.update.UpdateEventHandler;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.SVNDiffClient;
import org.tmatesoft.svn.core.wc.SVNDiffOptions;
import org.tmatesoft.svn.core.wc.SVNRevision;
@@ -55,11 +56,17 @@ public class BranchMerger implements IMerger {
myBranchName = branchName;
mySourceCopyRevision = sourceCopyRevision;
myAtStart = true;
SVNRepository repository = null;
try {
mySourceLatestRevision = myVcs.createRepository(mySourceUrl).getLatestRevision();
repository = myVcs.createRepository(mySourceUrl);
mySourceLatestRevision = repository.getLatestRevision();
}
catch (SVNException e) {
mySourceLatestRevision = SVNRevision.HEAD.getNumber();
} finally {
if (repository != null) {
repository.closeSession();
}
}
}
@@ -1099,10 +1099,13 @@ public class RepositoryBrowserDialog extends DialogWrapper {
SVNRepository sourceRepository = myVCS.createRepository(sourceURL.toString());
sourceRepository.setCanceller(new SvnProgressCanceller());
SvnDiffEditor diffEditor;
final long rev = sourceRepository.getLatestRevision();
final long rev;
SVNRepository targetRepository = null;
try {
rev = sourceRepository.getLatestRevision();
// generate Map of path->Change
diffEditor = new SvnDiffEditor(sourceRepository, myVCS.createRepository(targetURL.toString()), -1, false);
targetRepository = myVCS.createRepository(targetURL.toString());
diffEditor = new SvnDiffEditor(sourceRepository, targetRepository, -1, false);
final ISVNEditor cancellableEditor = SVNCancellableEditor.newInstance(diffEditor, new SvnProgressCanceller(), null);
sourceRepository.diff(targetURL, rev, rev, null, true, true, false, new ISVNReporterBaton() {
public void report(ISVNReporter reporter) throws SVNException {
@@ -1113,6 +1116,9 @@ public class RepositoryBrowserDialog extends DialogWrapper {
}
finally {
sourceRepository.closeSession();
if (targetRepository != null) {
targetRepository.closeSession();
}
}
final String sourceTitle = SVNPathUtil.tail(sourceURL.toString());
final String targetTitle = SVNPathUtil.tail(targetURL.toString());
@@ -120,12 +120,16 @@ public class SelectLocationDialog extends DialogWrapper {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
SVNRepository repos = null;
try {
SVNRepository repos = SvnVcs.getInstance(project).createRepository(urlString);
repos = SvnVcs.getInstance(project).createRepository(urlString);
result.set(repos.getRepositoryRoot(true));
repos.closeSession();
} catch (SVNException e) {
excRef.set(e);
} finally {
if (repos != null) {
repos.closeSession();
}
}
}
}, "Detecting repository root", true, project);
@@ -184,13 +184,17 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi
}
final String repositoryRoot;
SVNRepository repository = null;
try {
final SVNRepository repository = myVcs.createRepository(svnLocation.getURL());
repository = myVcs.createRepository(svnLocation.getURL());
repositoryRoot = repository.getRepositoryRoot(true).toString();
repository.closeSession();
}
catch (SVNException e) {
throw new VcsException(e);
} finally {
if (repository != null) {
repository.closeSession();
}
}
final ChangeBrowserSettings.Filter filter = settings.createFilter();
@@ -219,13 +223,18 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi
}
final String repositoryRoot;
SVNRepository repository = null;
try {
final SVNRepository repository = myVcs.createRepository(svnLocation.getURL());
repository = myVcs.createRepository(svnLocation.getURL());
repositoryRoot = repository.getRepositoryRoot(true).toString();
repository.closeSession();
}
catch (SVNException e) {
throw new VcsException(e);
} finally {
if (repository != null) {
repository.closeSession();
}
}
getCommittedChangesImpl(settings, svnLocation.getURL(), new String[]{""}, maxCount, new Consumer<SVNLogEntry>() {
@@ -249,13 +258,17 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi
}
final String repositoryRoot;
SVNRepository repository = null;
try {
final SVNRepository repository = myVcs.createRepository(svnLocation.getURL());
repository = myVcs.createRepository(svnLocation.getURL());
repositoryRoot = repository.getRepositoryRoot(true).toString();
repository.closeSession();
}
catch (SVNException e) {
throw new VcsException(e);
} finally {
if (repository != null) {
repository.closeSession();
}
}
final MergeTrackerProxy proxy = new MergeTrackerProxy(new Consumer<TreeStructureNode<SVNLogEntry>>() {
@@ -356,7 +369,17 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi
revisionBefore = SVNRevision.create(changeTo.longValue());
}
else {
revisionBefore = SVNRevision.create(myVcs.createRepository(url).getLatestRevision());
SVNRepository repository = null;
final long revision;
try {
repository = myVcs.createRepository(url);
revision = repository.getLatestRevision();
} finally {
if (repository != null) {
repository.closeSession();
}
}
revisionBefore = SVNRevision.create(revision);
}
final SVNRevision revisionAfter;
if (dateFrom != null) {
@@ -20,10 +20,10 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.update.UpdatedFiles;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnBundle;
import org.jetbrains.idea.svn.SvnConfiguration;
import org.jetbrains.idea.svn.SvnVcs;
import org.jetbrains.annotations.Nullable;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.io.SVNRepository;
@@ -131,14 +131,18 @@ public class SvnIntegrateEnvironment extends AbstractSvnUpdateIntegrateEnvironme
}
else {
SVNRepository repos = null;
try {
SVNRepository repos = myVcs.createRepository(svnURL2.toString());
repos = myVcs.createRepository(svnURL2.toString());
final long latestRev = repos.getLatestRevision();
repos.closeSession();
return String.valueOf(latestRev);
}
catch (SVNException e) {
return null;
} finally {
if (repos != null) {
repos.closeSession();
}
}
}
}