mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
committed by
intellij-monorepo-bot
parent
6a689e646c
commit
d76b7a109f
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user