mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix race Condition in UpdateRequestsQueue
Stopped can be switched into not stopped now.
This commit is contained in:
committed by
Kirill Likhodedov
parent
8804101b56
commit
134a1db80e
@@ -31,7 +31,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
@@ -39,6 +38,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
|
||||
/**
|
||||
* ChangeListManager updates scheduler.
|
||||
* Tries to zip several update requests into one (if starts and see several requests in the queue)
|
||||
@@ -204,22 +205,21 @@ public class UpdateRequestsQueue {
|
||||
}
|
||||
}
|
||||
|
||||
boolean stopped;
|
||||
synchronized (myLock) {
|
||||
if (! myStopped) {
|
||||
stopped = myStopped;
|
||||
if (!stopped) {
|
||||
myWaitingUpdateCompletionQueue.add(data.getCallback());
|
||||
schedule();
|
||||
}
|
||||
}
|
||||
// do not run under lock; stopped cannot be switched into not stopped - can check without lock
|
||||
if (myStopped) {
|
||||
if (stopped) {
|
||||
LOG.debug("invokeAfterUpdate: stopped, invoke right now for project: " + myProject.getName());
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (!myProject.isDisposed()) {
|
||||
afterUpdate.run();
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
if (!myProject.isDisposed()) {
|
||||
afterUpdate.run();
|
||||
}
|
||||
});
|
||||
}, notNull(state, ModalityState.defaultModalityState()));
|
||||
return;
|
||||
}
|
||||
// invoke progress if needed
|
||||
|
||||
Reference in New Issue
Block a user