Error in SonarLint for IntelliJ when opening project and closing that window before it's fully loade

Environment:

  • Java: JetBrains s.r.o. 17.0.6
  • OS: Linux amd64
  • IDE: IntelliJ IDEA 2023.1.1
  • SonarLint: 8.2.0.68615
java.lang.RuntimeException: Cannot invoke (class=ModuleChangeListener, method=modulesAdded, topic=ModuleListener)
	at c.ij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:657)
	at c.ij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:415)
	at c.ij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:394)
	at c.ij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
	at c.ij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:454)
	at jdk.proxy2/jdk.proxy2.$Proxy90.modulesAdded(Unknown Source)
	at c.ij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.fireModulesAdded(ModuleManagerComponentBridge.kt:338)
	at c.ij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.access$fireModulesAdded(ModuleManagerComponentBridge.kt:53)
	at c.ij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge$ModuleManagerInitProjectActivity.run(ModuleManagerComponentBridge.kt:61)
	at c.ij.ide.startup.impl.StartupManagerImpl.runInitProjectActivities(StartupManagerImpl.kt:215)
	at c.ij.ide.startup.impl.StartupManagerImpl.access$runInitProjectActivities(StartupManagerImpl.kt:69)
	at c.ij.ide.startup.impl.StartupManagerImpl$initProject$lambda$2$$inlined$useWithScope2$1.invokeSuspend(trace.kt:111)
	at c.ij.ide.startup.impl.StartupManagerImpl$initProject$lambda$2$$inlined$useWithScope2$1.invoke(trace.kt)
2023-05-16 13:18:07,230 [3126092]   INFO - #c.i.c.b.CompilerReferenceServiceBase - backward reference index reader is closed (didn't exist)
2023-05-16 13:18:08,171 [3127033] SEVERE - #c.i.o.p.i.ProjectManagerImpl - Cannot invoke (class=ModuleChangeListener, method=modulesAdded, topic=ModuleListener)
java.lang.RuntimeException: Cannot invoke (class=ModuleChangeListener, method=modulesAdded, topic=ModuleListener)
	at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:657)
	at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:415)
	at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:394)
	at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
	at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:454)
	at jdk.proxy2/jdk.proxy2.$Proxy90.modulesAdded(Unknown Source)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.fireModulesAdded(ModuleManagerComponentBridge.kt:338)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.access$fireModulesAdded(ModuleManagerComponentBridge.kt:53)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge$ModuleManagerInitProjectActivity.run(ModuleManagerComponentBridge.kt:61)
	at com.intellij.ide.startup.impl.StartupManagerImpl.runInitProjectActivities(StartupManagerImpl.kt:215)
	at com.intellij.ide.startup.impl.StartupManagerImpl.access$runInitProjectActivities(StartupManagerImpl.kt:69)
	at com.intellij.ide.startup.impl.StartupManagerImpl$initProject$lambda$2$$inlined$useWithScope2$1.invokeSuspend(trace.kt:111)
	at com.intellij.ide.startup.impl.StartupManagerImpl$initProject$lambda$2$$inlined$useWithScope2$1.invoke(trace.kt)
	at com.intellij.ide.startup.impl.StartupManagerImpl$initProject$lambda$2$$inlined$useWithScope2$1.invoke(trace.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.ide.startup.impl.StartupManagerImpl.initProject(StartupManagerImpl.kt:539)
	at com.intellij.openapi.project.impl.ProjectManagerImplKt$runInitProjectActivities$1.invokeSuspend(ProjectManagerImpl.kt:935)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
	Suppressed: java.lang.IllegalStateException: earlyDisposable was already disposed for Project(name=dynatrace-saas, containerState=DISPOSE_COMPLETED, componentStore=/mnt/data/workspaces/cluster2) (disposed)
---begin of dispose trace--null}---end of dispose trace---

		at com.intellij.openapi.project.impl.ProjectImpl.createEarlyDisposableError(ProjectImpl.kt:289)
		at com.intellij.openapi.project.impl.ProjectImpl.disposeEarlyDisposable(ProjectImpl.kt:281)
		at com.intellij.openapi.project.impl.ProjectManagerImpl.closeProject$lambda$11(ProjectManagerImpl.kt:340)
		at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:958)
		at com.intellij.openapi.project.impl.ProjectManagerImpl.closeProject(ProjectManagerImpl.kt:338)
		at com.intellij.openapi.project.impl.ProjectManagerImpl.closeProject$default(ProjectManagerImpl.kt:310)
		at com.intellij.openapi.project.impl.ProjectManagerImpl$doOpenAsync$4$1.invokeSuspend(ProjectManagerImpl.kt:686)
		at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
		at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
		at com.intellij.openapi.application.impl.DispatchedRunnable.run(DispatchedRunnable.kt:35)
		at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
		at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
		at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
		at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
		at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:456)
		at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:79)
		at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:122)
		at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
		at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
		at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:788)
		at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
		at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:731)
		at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
		at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
		at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:758)
		at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:666)
		at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$7(IdeEventQueue.kt:570)
		at com.intellij.openapi.application.impl.ApplicationImpl.withoutImplicitRead(ApplicationImpl.java:1446)
		at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:570)
		at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:68)
		at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:349)
		at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:348)
		at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
		at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:348)
		at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:343)
		at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:994)
		at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
		at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:994)
		at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$4(IdeEventQueue.kt:343)
		at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
		at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:385)
		at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
		at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
		at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
		at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
		at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
		at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Caused by: java.util.ConcurrentModificationException
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1221)
	at org.sonarlint.intellij.core.BackendService$Companion.moduleId(BackendService.kt:302)
	at org.sonarlint.intellij.core.BackendService.moduleAdded(BackendService.kt:228)
	at org.sonarlint.intellij.module.ModuleChangeListener.moduleAdded(ModuleChangeListener.kt:41)
	at com.intellij.openapi.project.ModuleListener.modulesAdded(ModuleListener.java:29)
	at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:680)
	at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:640)
	... 24 more

1 Like

Hello @thomas-k-dev,

Thanks for the report and the additional details, that was very useful :slight_smile:

I created this ticket, we will fix it next week and it will be part of the next release at the end of the month.

Thanks for using SonarLint!

2 Likes