diff --git a/platform/testFramework/src/com/intellij/testFramework/ThreadTracker.java b/platform/testFramework/src/com/intellij/testFramework/ThreadTracker.java index 284367106e76..d162fe80c69b 100644 --- a/platform/testFramework/src/com/intellij/testFramework/ThreadTracker.java +++ b/platform/testFramework/src/com/intellij/testFramework/ThreadTracker.java @@ -20,7 +20,7 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.impl.ProjectManagerImpl; import com.intellij.openapi.util.Condition; import com.intellij.util.ReflectionUtil; -import com.intellij.util.TimeoutUtil; +import com.intellij.util.WaitFor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtilRt; import gnu.trove.THashSet; @@ -110,7 +110,7 @@ public class ThreadTracker { Collection after = new THashSet(getThreads()); after.removeAll(before); - for (Thread thread : after) { + for (final Thread thread : after) { if (thread == Thread.currentThread()) continue; ThreadGroup group = thread.getThreadGroup(); if (group != null && "system".equals(group.getName()))continue; @@ -126,8 +126,15 @@ public class ThreadTracker { if (!thread.isAlive()) continue; if (thread.getStackTrace().length == 0) { - TimeoutUtil.sleep(10000); - if (!thread.isAlive()) continue; + thread.interrupt(); + if (new WaitFor(10000){ + @Override + protected boolean condition() { + return !thread.isAlive(); + } + }.isConditionRealized()) { + continue; + } } String trace = "Thread leaked: " + thread+"; " + thread.getState()+" ("+ thread.isAlive()+")\n--- its stacktrace:\n"; diff --git a/platform/util/src/com/intellij/util/ConcurrencyUtil.java b/platform/util/src/com/intellij/util/ConcurrencyUtil.java index 37e54a011ad1..2330616d57fb 100644 --- a/platform/util/src/com/intellij/util/ConcurrencyUtil.java +++ b/platform/util/src/com/intellij/util/ConcurrencyUtil.java @@ -151,7 +151,7 @@ public class ConcurrencyUtil { } if (executor.getPoolSize() != 0) { String dump = ThreadDumper.dumpThreadsToString(); - System.err.println("Executor "+executor+" is still active after "+unit.toSeconds(timeout)+" seconds:\n"+ dump); + System.err.println("Executor "+executor+" is still active after "+unit.toSeconds(timeout)+" seconds://///\n"+ dump+"\n/////"); } } }