IDEA-200807 NPE caused by NonClasspathClassFinder constructor leaking "this"

This commit is contained in:
peter
2018-11-12 18:23:21 +01:00
parent 81a73c9e26
commit a84948269c
2 changed files with 2 additions and 7 deletions
@@ -52,7 +52,7 @@ public abstract class NonClasspathClassFinder extends PsiElementFinder {
clearCache();
}
});
LowMemoryWatcher.register(() -> clearCache(), project);
LowMemoryWatcher.register(() -> myCache = null, project);
}
@NotNull
@@ -67,12 +67,7 @@ public class GradleClassFinder extends NonClasspathClassFinder {
@Override
public void clearCache() {
super.clearCache();
// The parent class can publish a reference to this object before the constructor has returned.
// Thus, it's possible that not all fields of this object are initialized by the time they
// are accessed in clearCache(). Workaround is to null check.
if (myCaches != null) {
myCaches.clear();
}
myCaches.clear();
}
@Override