mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
sort, cleanup
This commit is contained in:
@@ -19,7 +19,6 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.impl.ProjectManagerImpl;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
@@ -66,7 +65,7 @@ public class ThreadTracker {
|
||||
return ContainerUtilRt.newArrayList(threads);
|
||||
}
|
||||
|
||||
private static final Set<String> wellKnownOffenders = new THashSet<String>();
|
||||
private static final Set<String> wellKnownOffenders = new THashSet<>();
|
||||
static {
|
||||
wellKnownOffenders.add("AWT-EventQueue-");
|
||||
wellKnownOffenders.add("AWT-Shutdown");
|
||||
@@ -81,10 +80,10 @@ public class ThreadTracker {
|
||||
wellKnownOffenders.add("Keep-Alive-Timer");
|
||||
wellKnownOffenders.add("main");
|
||||
wellKnownOffenders.add("Monitor Ctrl-Break");
|
||||
wellKnownOffenders.add("Netty ");
|
||||
wellKnownOffenders.add("Reference Handler");
|
||||
wellKnownOffenders.add("RMI TCP Connection");
|
||||
wellKnownOffenders.add("Signal Dispatcher");
|
||||
wellKnownOffenders.add("Netty ");
|
||||
wellKnownOffenders.add("timer-int"); //serverImpl
|
||||
wellKnownOffenders.add("timer-sys"); //clientimpl
|
||||
wellKnownOffenders.add("TimerQueue");
|
||||
@@ -100,12 +99,7 @@ public class ThreadTracker {
|
||||
public static void longRunningThreadCreated(@NotNull Disposable parentDisposable,
|
||||
@NotNull final String... threadNamePrefixes) {
|
||||
wellKnownOffenders.addAll(Arrays.asList(threadNamePrefixes));
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
wellKnownOffenders.removeAll(Arrays.asList(threadNamePrefixes));
|
||||
}
|
||||
});
|
||||
Disposer.register(parentDisposable, () -> wellKnownOffenders.removeAll(Arrays.asList(threadNamePrefixes)));
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@@ -115,7 +109,7 @@ public class ThreadTracker {
|
||||
try {
|
||||
if (myDefaultProjectInitialized != ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized()) return;
|
||||
|
||||
Collection<Thread> after = new THashSet<Thread>(getThreads());
|
||||
Collection<Thread> after = new THashSet<>(getThreads());
|
||||
after.removeAll(before);
|
||||
|
||||
for (final Thread thread : after) {
|
||||
@@ -123,12 +117,7 @@ public class ThreadTracker {
|
||||
ThreadGroup group = thread.getThreadGroup();
|
||||
if (group != null && "system".equals(group.getName()))continue;
|
||||
final String name = thread.getName();
|
||||
if (ContainerUtil.exists(wellKnownOffenders, new Condition<String>() {
|
||||
@Override
|
||||
public boolean value(String pattern) {
|
||||
return name.contains(pattern);
|
||||
}
|
||||
})) {
|
||||
if (ContainerUtil.exists(wellKnownOffenders, name::contains)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -149,7 +138,8 @@ public class ThreadTracker {
|
||||
continue; // ignore threads with empty stack traces for now. Seems they are zombies unwilling to die.
|
||||
}
|
||||
|
||||
String trace = "Thread leaked: " + thread+"; " + thread.getState()+" ("+ thread.isAlive()+")\n--- its stacktrace:\n";
|
||||
@SuppressWarnings("NonConstantStringShouldBeStringBuffer")
|
||||
String trace = "Thread leaked: " + thread + "; " + thread.getState() + " (" + thread.isAlive() + ")\n--- its stacktrace:\n";
|
||||
for (final StackTraceElement stackTraceElement : stackTrace) {
|
||||
trace += " at "+stackTraceElement +"\n";
|
||||
}
|
||||
@@ -165,12 +155,9 @@ public class ThreadTracker {
|
||||
public static void awaitThreadTerminationWithParentParentGroup(@NotNull final String grandThreadGroup, int timeout, @NotNull TimeUnit unit) {
|
||||
long start = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() < start + unit.toMillis(timeout)) {
|
||||
Thread jdiThread = ContainerUtil.find(getThreads(), new Condition<Thread>() {
|
||||
@Override
|
||||
public boolean value(Thread thread) {
|
||||
ThreadGroup group = thread.getThreadGroup();
|
||||
return group != null && group.getParent() != null && grandThreadGroup.equals(group.getParent().getName());
|
||||
}
|
||||
Thread jdiThread = ContainerUtil.find(getThreads(), thread -> {
|
||||
ThreadGroup group = thread.getThreadGroup();
|
||||
return group != null && group.getParent() != null && grandThreadGroup.equals(group.getParent().getName());
|
||||
});
|
||||
|
||||
if (jdiThread == null) {
|
||||
|
||||
Reference in New Issue
Block a user