Clear interned stacktraces on plugin unload (IDEA-240458)

GitOrigin-RevId: 56943a9f75957079bfce9d3a38498391e344f8dd
This commit is contained in:
Dmitry Jemerov
2020-06-02 21:35:36 +03:00
committed by intellij-monorepo-bot
parent d971c1aedc
commit 9081b0dae5
3 changed files with 18 additions and 4 deletions
@@ -43,6 +43,7 @@ import com.intellij.openapi.project.ex.ProjectManagerEx
import com.intellij.openapi.project.impl.ProjectImpl
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.IconLoader
import com.intellij.openapi.util.objectTree.ThrowableInterner
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.wm.WindowManager
import com.intellij.openapi.wm.impl.ProjectFrameHelper
@@ -452,6 +453,7 @@ object DynamicPlugins {
// do it after IdeEventQueue.flushQueue() to ensure that Disposer.isDisposed(...) works as expected in flushed tasks.
Disposer.clearDisposalTraces() // ensure we don't have references to plugin classes in disposal backtraces
ThrowableInterner.clearInternedBacktraces()
IdeaLogger.ourErrorsOccurred = null // ensure we don't have references to plugin classes in exception stacktraces
clearTemporaryLostComponent()
@@ -133,4 +133,10 @@ public class ThrowableInterner {
public static Throwable intern(@NotNull Throwable throwable) {
return getBacktrace(throwable) == null ? throwable : myTraceInterner.intern(throwable);
}
public static void clearInternedBacktraces() {
for (Throwable t : myTraceInterner.getValues()) {
clearBacktrace(t);
}
}
}
@@ -24,9 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
/**
@@ -294,7 +292,15 @@ public class ConcurrentWeakKeySoftValueHashMap<K, V> implements ConcurrentMap<K,
@NotNull
@Override
public Collection<V> values() {
throw new UnsupportedOperationException();
List<V> values = new ArrayList<>();
processQueues();
for (ValueReference<K, V> valueReference : myMap.values()) {
V v = com.intellij.reference.SoftReference.deref(valueReference);
if (v != null) {
values.add(v);
}
}
return values;
}
@NotNull