mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[threading] IJPL-216787: Avoid deadlock with synchronous refresh invoked inside background write action
GitOrigin-RevId: e4a3a51cf17acf430cce38165377a7d7d06126a7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d607ec531d
commit
943655cbdc
@@ -70,7 +70,7 @@ class RefreshQueueImpl(coroutineScope: CoroutineScope) : RefreshQueue(), Disposa
|
||||
queueSession(session, session.modality)
|
||||
}
|
||||
}
|
||||
else if (EDT.isCurrentThreadEdt()) {
|
||||
else if (EDT.isCurrentThreadEdt() || ApplicationManager.getApplication().isWriteAccessAllowed) {
|
||||
(TransactionGuard.getInstance() as TransactionGuardImpl).assertWriteActionAllowed()
|
||||
val events = runRefreshSession(session, -1L)
|
||||
fireEvents(events, session)
|
||||
|
||||
+13
@@ -231,4 +231,17 @@ class VfsRefreshTest {
|
||||
}
|
||||
assertEquals(currentCounter, newCounter, "There should be no write action if there was nothing to refresh")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `synchronous refresh in a background write action can terminate successfully`() = timeoutRunBlocking {
|
||||
val file = createTempFile()
|
||||
val virtualFile = VirtualFileManager.getInstance().findFileByNioPath(file)!!
|
||||
writeAction {
|
||||
virtualFile.writeText("42")
|
||||
}
|
||||
backgroundWriteAction {
|
||||
virtualFile.refresh(false, false)
|
||||
}
|
||||
// if this test terminates, there was no hanging
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user