From 41f7bbaed57d4b789ac60c1566e83644efbe52a8 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Wed, 13 Dec 2017 12:59:08 +0300 Subject: [PATCH] hg tests: freeze CLM before project closed * if CLM starts async update after waitEverythingDoneInTestMode but before projectClosed then Hg may start its command, it will be cancelled with indicator, but inherited threads in DataBaseReader can survive for a while, because synchronize block in com.intellij.util.io.BaseDataReader.doRun() can postpone stop method while holding mySleepMonitor in a wait method. ThreadChecker doesn't interrupt such threads and catches them in a waiting state -> Thread leak may appear. --- .../intellij/tasks/vcs/HgTaskBranchesTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/vcs/HgTaskBranchesTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/vcs/HgTaskBranchesTest.java index 8f89c1c6a000..d18aa7eac219 100644 --- a/plugins/tasks/tasks-tests/test/com/intellij/tasks/vcs/HgTaskBranchesTest.java +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/vcs/HgTaskBranchesTest.java @@ -18,6 +18,7 @@ package com.intellij.tasks.vcs; import com.intellij.dvcs.repo.Repository; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.ProjectLevelVcsManager; +import com.intellij.openapi.vcs.changes.ChangeListManagerImpl; import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.util.ObjectUtils; @@ -45,6 +46,20 @@ public class HgTaskBranchesTest extends TaskBranchesTest { hgVcs.getGlobalSettings().setHgExecutable(HgExecutor.getHgExecutable()); } + @Override + protected void tearDown() throws Exception { + try { + // if CLM starts async update after waitEverythingDoneInTestMode but before projectClosed then Hg may start its command, + // it will be cancelled with indicator, but inherited threads in DataBaseReader can survive for a while, + // because synchronize block in com.intellij.util.io.BaseDataReader.doRun() can postpone stop method while holding mySleepMonitor. + // ThreadChecker doesn't interrupt such threads and catches them in a waiting state -> Thread leak may appear. + ChangeListManagerImpl.getInstanceImpl(myProject).freeze("For Tests"); + } + finally { + super.tearDown(); + } + } + @NotNull @Override protected Repository initRepository(@NotNull String name) {