WEB-76271 PolySymbols/tests: fix problems with caching in KeyedExtensionCollector

- cache should not be used if extension point listener is not registered
- allow adding a new listener once an area is replaced
- always notify that area is replaced.

GitOrigin-RevId: 3d91be0598bc11a2cc193a764195a814d5be738c
This commit is contained in:
Piotr Tomiak
2026-01-10 01:01:12 +00:00
committed by intellij-monorepo-bot
parent 6a689e646c
commit d76b7a109f
2 changed files with 8 additions and 1 deletions
@@ -111,6 +111,8 @@ public class KeyedExtensionCollector<T, KeyT> implements ModificationTracker {
cached = buildExtensions(stringKey, key);
if (!myEpListenerAdded.get()) return cached;
synchronized (lock) {
List<T> recent = cache.get(stringKey);
if (recent != null) {
@@ -296,6 +298,7 @@ public class KeyedExtensionCollector<T, KeyT> implements ModificationTracker {
public void areaReplaced(@NotNull ExtensionsArea area) {
synchronized (lock) {
cache = Java11Shim.INSTANCE.mapOf();
myEpListenerAdded.set(false);
tracker.incModificationCount();
}
}
@@ -37,6 +37,9 @@ public final class Extensions {
public static void setRootArea(@NotNull ExtensionsAreaImpl area, @NotNull Disposable parentDisposable) {
ExtensionsAreaImpl oldRootArea = staticRootArea;
staticRootArea = area;
if (oldRootArea != null) {
oldRootArea.notifyAreaReplaced(area);
}
Disposer.register(parentDisposable, () -> {
staticRootArea.notifyAreaReplaced(oldRootArea);
staticRootArea = oldRootArea;
@@ -51,7 +54,8 @@ public final class Extensions {
public static ExtensionsArea getRootArea() {
if (rootSupplier != null) {
return rootSupplier.get();
} else {
}
else {
return staticRootArea;
}
}