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.
This commit is contained in:
Nadya Zabrodina
2017-12-13 13:10:58 +03:00
parent 4bec1e62c0
commit 41f7bbaed5
@@ -18,6 +18,7 @@ package com.intellij.tasks.vcs;
import com.intellij.dvcs.repo.Repository; import com.intellij.dvcs.repo.Repository;
import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl; import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.util.ObjectUtils; import com.intellij.util.ObjectUtils;
@@ -45,6 +46,20 @@ public class HgTaskBranchesTest extends TaskBranchesTest {
hgVcs.getGlobalSettings().setHgExecutable(HgExecutor.getHgExecutable()); 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 @NotNull
@Override @Override
protected Repository initRepository(@NotNull String name) { protected Repository initRepository(@NotNull String name) {