From e667ec54cede57a18051c5d9a246d44fbe7800a9 Mon Sep 17 00:00:00 2001 From: Liudmila Kornilova Date: Thu, 21 Mar 2024 13:26:54 +0100 Subject: [PATCH] IDEA-348980 Catch VfsRootAccessNotAllowedError when getting VirtualFile for dirty files (to schedule them for indexing) GitOrigin-RevId: 718d43d6a298ee3193630f4cc4ba0b91d4fde71b --- .../indexing/unindexedFilesScannerStartup.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/unindexedFilesScannerStartup.kt b/platform/lang-impl/src/com/intellij/util/indexing/unindexedFilesScannerStartup.kt index d0060a4e04a9..ce8577355276 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/unindexedFilesScannerStartup.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/unindexedFilesScannerStartup.kt @@ -10,6 +10,7 @@ import com.intellij.openapi.util.UserDataHolderEx import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.newvfs.ManagingFS +import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.VfsRootAccessNotAllowedError import com.intellij.util.indexing.PersistentDirtyFilesQueue.getQueueFile import com.intellij.util.indexing.PersistentDirtyFilesQueue.removeCurrentFile import com.intellij.util.indexing.UnindexedFilesScanner.LOG @@ -101,10 +102,22 @@ private suspend fun findProjectFiles(project: Project, dirtyFilesIds: Collection return readAction { val fs = ManagingFS.getInstance() val fileBasedIndex = FileBasedIndex.getInstance() as FileBasedIndexImpl + var exceptionLogged = false dirtyFilesIds.asSequence() .mapNotNull { fileId -> - val file = fs.findFileById(fileId) - if (file != null && fileBasedIndex.getContainingProjects(file).contains(project)) file else null + try { + val file = fs.findFileById(fileId) + if (file != null && fileBasedIndex.getContainingProjects(file).contains(project)) file else null + } + catch (e: VfsRootAccessNotAllowedError) { + if (!exceptionLogged) { + LOG.debug("VfsRootAccessNotAllowedError occurred. " + + "Probably previous test with different rules for project roots saved these files to dirty files queue. " + + "Example of error:", e) + exceptionLogged = true + } + null + } }.run { if (limit <= 0) this else this.take(limit)