From 976d4b6edfe223956e0fef23fd1937f2a7adb45f Mon Sep 17 00:00:00 2001 From: "Andrei.Kuznetsov" Date: Wed, 27 Mar 2024 17:54:58 +0100 Subject: [PATCH] Enable multithreaded indexing in unit tests (and other headless environments) GitOrigin-RevId: c06beda02d20e8b8f9f0cb8eb7c8d3f0910c8ebc --- .../roots/impl/PushedFilePropertiesUpdaterImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java index 6538464d1503..0903f093620e 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java @@ -382,7 +382,14 @@ public final class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesU public static void invokeConcurrentlyIfPossible(@NotNull List tasks) { if (tasks.isEmpty()) return; - if (tasks.size() == 1 || ApplicationManager.getApplication().isWriteAccessAllowed() || DumbServiceImpl.isSynchronousTaskExecution()) { + boolean synchronous = (tasks.size() == 1); + if (DumbServiceImpl.isSynchronousTaskExecution()) { + synchronous = true; + } + else { + LOG.assertTrue(!ApplicationManager.getApplication().isWriteAccessAllowed(), "Write access is not allowed"); + } + if (synchronous) { for (Runnable r : tasks) r.run(); return; }