IJPL-248392 LSP: remove race condition in LspDocumentSyncManager.close

(cherry picked from commit e9e964c16ee2240aa45eed11671b626970de4c13)

IJ-CR-210268

GitOrigin-RevId: 632b359925c3ad4147e788373e69a03f22418e08
This commit is contained in:
Piotr Tomiak
2026-08-19 18:48:46 +00:00
committed by intellij-monorepo-bot
parent 626818b4b5
commit a96d0841a8
@@ -46,8 +46,8 @@ internal class LspDocumentSyncManager(private val client: LspClientImpl) {
fun forEachOpenedFile(action: (VirtualFile) -> Unit) = openedFiles.forEach(action)
fun shutdown() {
openedFiles.clear()
shutdown.set(true)
openedFiles.clear()
}
@RequiresWriteLock
@@ -81,7 +81,7 @@ internal class LspDocumentSyncManager(private val client: LspClientImpl) {
@RequiresWriteLock
fun close(file: VirtualFile) {
if (!openedFiles.remove(file)) {
if (!openedFiles.remove(file) || shutdown.get()) {
// Error should not be logged if the sync manager is disposed of, as the server state
// and thus sync manager state might have changed just after entering `open` method
// and caller is not able to sync on the server state