mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NPE in injected due to datarace in isPhysical()
This commit is contained in:
@@ -79,6 +79,11 @@ public final class Annotation implements Segment {
|
||||
displayName = key != null ? HighlightDisplayKey.getDisplayNameByKey(key) : fix.getText();
|
||||
options = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return quickFix.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+10
-5
@@ -41,7 +41,12 @@ public class InjectedFileViewProvider extends SingleRootFileViewProvider {
|
||||
private Project myProject;
|
||||
private final Object myLock = new Object();
|
||||
private final DocumentWindow myDocumentWindow;
|
||||
private volatile boolean physical = true;
|
||||
private static final ThreadLocal<Boolean> disabledTemporarily = new ThreadLocal<Boolean>(){
|
||||
@Override
|
||||
protected Boolean initialValue() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
InjectedFileViewProvider(@NotNull PsiManager psiManager,
|
||||
@NotNull VirtualFileWindow virtualFile,
|
||||
@@ -142,7 +147,7 @@ public class InjectedFileViewProvider extends SingleRootFileViewProvider {
|
||||
@Override
|
||||
public boolean isEventSystemEnabled() {
|
||||
if (myLock == null) return true; // hack to avoid NPE when this method called from super class constructor
|
||||
return physical;
|
||||
return !disabledTemporarily.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,18 +157,18 @@ public class InjectedFileViewProvider extends SingleRootFileViewProvider {
|
||||
|
||||
public void performNonPhysically(Runnable runnable) {
|
||||
synchronized (myLock) {
|
||||
physical = false;
|
||||
disabledTemporarily.set(true);
|
||||
try {
|
||||
runnable.run();
|
||||
}
|
||||
finally {
|
||||
physical = true;
|
||||
disabledTemporarily.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Injected file '"+getVirtualFile().getName()+"' " + (isValid() ? "" : " invalid") + (physical ? "" : " nonphysical");
|
||||
return "Injected file '"+getVirtualFile().getName()+"' " + (isValid() ? "" : " invalid") + (isPhysical() ? "" : " nonphysical");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user