From 75fc3802fcaf1966d830b8cb2fa0e4e8facb0bd0 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 23 Jan 2017 16:51:37 +0300 Subject: [PATCH] clear fields after test run to avoid leaks when the test class instance stuck in queues --- .../intellij/openapi/roots/impl/DirectoryIndexTest.java | 9 +++++++++ .../debugger/ExecutionWithDebuggerToolsTestCase.java | 4 ++++ .../src/com/intellij/execution/ExecutionTestCase.java | 2 ++ .../com/intellij/vcs/log/data/VcsLogRefresherTest.java | 7 +++++++ .../com/intellij/xdebugger/XBreakpointsTestCase.java | 7 ++++++- .../intellij/xdebugger/XDependentBreakpointsTest.java | 6 ++++++ .../test/com/intellij/tasks/vcs/TaskBranchesTest.java | 1 + 7 files changed, 35 insertions(+), 1 deletion(-) diff --git a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java index f0d62a00681f..8eb8271c0ae1 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java @@ -179,6 +179,15 @@ public class DirectoryIndexTest extends IdeaTestCase { VirtualFileManager.getInstance().syncRefresh(); } + @Override + protected void tearDown() throws Exception { + myFileIndex = null; + myIndex = null; + myModule2 = null; + myModule3 = null; + super.tearDown(); + } + private CompilerProjectExtension getCompilerProjectExtension() { final CompilerProjectExtension instance = CompilerProjectExtension.getInstance(myProject); assertNotNull(instance); diff --git a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java index df42d962bf85..e5dd1aac1664 100644 --- a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java +++ b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java @@ -140,6 +140,9 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa protected void tearDown() throws Exception { ThreadTracker.awaitThreadTerminationWithParentParentGroup("JDI main", 100, TimeUnit.SECONDS); try { + myDebugProcess = null; + myPauseScriptListener = null; + myRatherLaterRequests.clear(); super.tearDown(); } finally { @@ -150,6 +153,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa protected void throwExceptionsIfAny() { synchronized (myException) { CompoundRuntimeException.throwIfNotEmpty(myException); + myException.clear(); } } diff --git a/java/testFramework/src/com/intellij/execution/ExecutionTestCase.java b/java/testFramework/src/com/intellij/execution/ExecutionTestCase.java index d57f78d124f5..b3f91dae48c7 100644 --- a/java/testFramework/src/com/intellij/execution/ExecutionTestCase.java +++ b/java/testFramework/src/com/intellij/execution/ExecutionTestCase.java @@ -132,7 +132,9 @@ public abstract class ExecutionTestCase extends IdeaTestCase { protected void tearDown() throws Exception { if (myCompilerTester != null) { myCompilerTester.tearDown(); + myCompilerTester = null; } + myChecker = null; EdtTestUtil.runInEdtAndWait(() -> super.tearDown()); //myChecker.checkValid(getTestProjectJdk()); //probably some thread is destroyed right now because of log exception diff --git a/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogRefresherTest.java b/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogRefresherTest.java index ed6c53c57fb5..2c37a47d5873 100644 --- a/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogRefresherTest.java +++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogRefresherTest.java @@ -83,6 +83,13 @@ public class VcsLogRefresherTest extends VcsPlatformTest { } } finally { + myLogData = null; + myLoader = null; + myLogProvider = null; + myCommits = null; + myDataWaiter = null; + myStartedTasks.clear(); + changeListManager = null; super.tearDown(); } } diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XBreakpointsTestCase.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XBreakpointsTestCase.java index 9bc3e13cf537..74a862b0f185 100644 --- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XBreakpointsTestCase.java +++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XBreakpointsTestCase.java @@ -28,7 +28,6 @@ import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl; import org.jdom.Element; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -45,6 +44,12 @@ public abstract class XBreakpointsTestCase extends XDebuggerTestCase { myTempFiles = new TempFiles(myFilesToDelete); } + @Override + protected void tearDown() throws Exception { + myBreakpointManager = null; + super.tearDown(); + } + protected void load(final Element element) { XBreakpointManagerImpl.BreakpointManagerState managerState = XmlSerializer.deserialize(element, XBreakpointManagerImpl.BreakpointManagerState.class); myBreakpointManager.loadState(managerState); diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDependentBreakpointsTest.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDependentBreakpointsTest.java index 89c3dce9cc9d..7047a2f06114 100644 --- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDependentBreakpointsTest.java +++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDependentBreakpointsTest.java @@ -35,6 +35,12 @@ public class XDependentBreakpointsTest extends XBreakpointsTestCase { myDependentBreakpointManager = myBreakpointManager.getDependentBreakpointManager(); } + @Override + protected void tearDown() throws Exception { + myDependentBreakpointManager = null; + super.tearDown(); + } + public void testDelete() throws Exception { XLineBreakpoint master = createMaster(); XLineBreakpoint slave = createSlave(); diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/vcs/TaskBranchesTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/vcs/TaskBranchesTest.java index e72dfe803be1..f43a20cf5470 100644 --- a/plugins/tasks/tasks-tests/test/com/intellij/tasks/vcs/TaskBranchesTest.java +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/vcs/TaskBranchesTest.java @@ -49,6 +49,7 @@ public abstract class TaskBranchesTest extends PlatformTestCase { ((ChangeListManagerImpl)ChangeListManager.getInstance(myProject)).waitEverythingDoneInTestMode(); } finally { + myTaskManager = null; super.tearDown(); } }