From 53dec997ed13343693cb3ad75a1dabeac0e90704 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 13 Feb 2017 20:41:59 +0300 Subject: [PATCH] check the project is disposed under the lock. When the project closes the queue is cleared under that same lock. --- .../com/intellij/psi/impl/DocumentCommitThread.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java index 7b219916d8b0..6d109c51695f 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java @@ -164,14 +164,14 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi PsiDocumentManager.getInstance(project).getLastCommittedText(document)); } - @NotNull - private CommitTask doQueue(@NotNull Project project, + private void doQueue(@NotNull Project project, @NotNull Document document, @NotNull List> oldFileNodes, @NotNull Object reason, @NotNull ModalityState currentModalityState, @NotNull CharSequence lastCommittedText) { synchronized (lock) { + if (!project.isInitialized()) return; // check the project is disposed under lock. CommitTask newTask = createNewTaskAndCancelSimilar(project, document, oldFileNodes, reason, currentModalityState, lastCommittedText); @@ -179,7 +179,6 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi log(project, "Queued", newTask, reason); wakeUpQueue(); - return newTask; } } @@ -556,10 +555,8 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi if (task.reason.equals(SYNC_COMMIT_REASON)) { throw new PsiInvalidElementAccessException(file, "File " + file + " invalidated during sync commit"); } - else { - commitAsynchronously(project, document, "File " + file + " invalidated during background commit; task: "+task, - task.myCreationModalityState); - } + commitAsynchronously(project, document, "File " + file + " invalidated during background commit; task: "+task, + task.myCreationModalityState); } } }