From 64c6ad957eaaa81eee64b443a31fc6bb514f7e38 Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 31 Jan 2013 18:07:54 +0400 Subject: [PATCH] IDEA-98776 Memory Leak found 3 additional places where default svnkit pool was used -> create all clients through SvnVcs factory methods, with our no caching pool -> no auto refresh scheduled queue, no leak --- .../idea/svn/SvnAuthenticationNotifier.java | 3 +- .../src/org/jetbrains/idea/svn/SvnVcs.java | 18 ++++++++ .../idea/svn/branchConfig/BranchesLoader.java | 7 +-- .../SvnCommandLineUpdateClient.java | 3 +- .../dialogs/SvnAuthenticationProvider.java | 2 - .../jetbrains/idea/svn/SvnAndProxyTest.java | 43 +++++++++++++++++++ 6 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAndProxyTest.java diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java index 70dcbb1eed2d..cdf92851c5ce 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java @@ -48,7 +48,6 @@ import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.SVNAuthentication; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNWCClient; import javax.swing.*; import java.awt.*; @@ -351,7 +350,7 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl { return client; } + public SVNUpdateClient createUpdateClient(@NotNull ISVNAuthenticationManager manager) { + final SVNUpdateClient client = new SVNUpdateClient(getPool(), myConfiguration.getOptions(myProject)); + client.getOperationsFactory().setAuthenticationManager(manager); + return client; + } + public SVNStatusClient createStatusClient() { SVNStatusClient client = new SVNStatusClient(getPool(), myConfiguration.getOptions(myProject)); client.getOperationsFactory().setAuthenticationManager(myConfiguration.getAuthenticationManager(this)); @@ -680,6 +686,12 @@ public class SvnVcs extends AbstractVcs { return client; } + public SVNWCClient createWCClient(@NotNull ISVNAuthenticationManager manager) { + final SVNWCClient client = new SVNWCClient(getPool(), myConfiguration.getOptions(myProject)); + client.getOperationsFactory().setAuthenticationManager(manager); + return client; + } + public SVNCopyClient createCopyClient() { final SVNCopyClient client = new SVNCopyClient(getPool(), myConfiguration.getOptions(myProject)); client.getOperationsFactory().setAuthenticationManager(myConfiguration.getAuthenticationManager(this)); @@ -698,6 +710,12 @@ public class SvnVcs extends AbstractVcs { return client; } + public SVNLogClient createLogClient(@NotNull ISVNAuthenticationManager manager) { + final SVNLogClient client = new SVNLogClient(getPool(), myConfiguration.getOptions(myProject)); + client.getOperationsFactory().setAuthenticationManager(manager); + return client; + } + public SVNCommitClient createCommitClient() { final SVNCommitClient client = new SVNCommitClient(getPool(), myConfiguration.getOptions(myProject)); client.getOperationsFactory().setAuthenticationManager(myConfiguration.getAuthenticationManager(this)); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java index 7eac0632a910..2164ccd48682 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java @@ -39,10 +39,11 @@ public class BranchesLoader { final List result = new LinkedList(); final SvnConfiguration configuration = SvnConfiguration.getInstance(project); - final ISVNAuthenticationManager passiveManager = passive ? configuration.getPassiveAuthenticationManager(project) : configuration.getInteractiveManager( - SvnVcs.getInstance(project)); + final SvnVcs vcs = SvnVcs.getInstance(project); + final ISVNAuthenticationManager passiveManager = passive ? + configuration.getPassiveAuthenticationManager(project) : configuration.getInteractiveManager(vcs); - final SVNLogClient logClient = new SVNLogClient(passiveManager, configuration.getOptions(project)); + final SVNLogClient logClient = vcs.createLogClient(passiveManager); final SVNURL branchesUrl = SVNURL.parseURIEncoded(url); logClient.doList(branchesUrl, SVNRevision.UNDEFINED, SVNRevision.HEAD, false, SVNDepth.IMMEDIATES, SVNDirEntry.DIRENT_ALL, new ISVNDirEntryHandler() { public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandLineUpdateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandLineUpdateClient.java index ae68233c985a..4870183b9823 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandLineUpdateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandLineUpdateClient.java @@ -22,7 +22,6 @@ import com.intellij.openapi.vcs.LineProcessEventListener; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.concurrency.Semaphore; import org.jetbrains.idea.svn.SvnAuthenticationManager; -import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.portable.SvnExceptionWrapper; import org.jetbrains.idea.svn.portable.SvnSvnkitUpdateClient; @@ -166,7 +165,7 @@ public class SvnCommandLineUpdateClient extends SvnSvnkitUpdateClient { @Override public void runWithSvnkitClient(File configDir, SvnAuthenticationManager manager) throws SVNException { - final SVNUpdateClient client = new SVNUpdateClient(manager, SvnConfiguration.getInstance(myProject).getOptions(myProject)); + final SVNUpdateClient client = SvnVcs.getInstance(myProject).createUpdateClient(manager); client.doUpdate(paths, revision, depth, allowUnversionedObstructions, depthIsSticky, makeParents); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnAuthenticationProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnAuthenticationProvider.java index a56fa6cc28d3..6638f5ce75d1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnAuthenticationProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnAuthenticationProvider.java @@ -40,13 +40,11 @@ public class SvnAuthenticationProvider implements ISVNAuthenticationProvider { private final Project myProject; private final SvnAuthenticationNotifier myAuthenticationNotifier; private final ISVNAuthenticationProvider mySvnInteractiveAuthenticationProvider; - private final SvnVcs mySvnVcs; private final ISVNAuthenticationStorage myAuthenticationStorage; private static final Set ourForceInteractive = new HashSet(); public SvnAuthenticationProvider(final SvnVcs svnVcs, final ISVNAuthenticationProvider provider, final ISVNAuthenticationStorage authenticationStorage) { - mySvnVcs = svnVcs; myAuthenticationStorage = authenticationStorage; myProject = svnVcs.getProject(); myAuthenticationNotifier = svnVcs.getAuthNotifier(); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAndProxyTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAndProxyTest.java new file mode 100644 index 000000000000..b20b4a8c8279 --- /dev/null +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAndProxyTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn; + +import com.intellij.util.net.HttpConfigurable; +import org.junit.Test; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 1/31/13 + * Time: 3:37 PM + */ +public class SvnAndProxyTest extends Svn17TestCase { + @Test + public void testDirectWhenIdeaHaveProxy() throws Exception { + + + } + + private static void setDefaultFixedProxySettings() { + final HttpConfigurable h = HttpConfigurable.getInstance(); + h.USE_PROXY_PAC = false; + h.USE_HTTP_PROXY = true; + h.AUTHENTICATION_CANCELLED = false; + // doesn't matter, only significant for serialization + h.KEEP_PROXY_PASSWORD = false; + h.LAST_ERROR = null; + } +}