Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probable race condition between CSharpier, Rider #573

Closed
commonquail opened this issue Jan 26, 2022 · 7 comments · Fixed by #576
Closed

Probable race condition between CSharpier, Rider #573

commonquail opened this issue Jan 26, 2022 · 7 comments · Fixed by #576
Labels
area:rider type:bug Something isn't working

Comments

@commonquail
Copy link

  • CSharpier 0.11.1
  • Rider plugin 1.2.0-beta2

This happened immediately after a "move class to file" refactoring and my guess is this is the equivalent of a concurrent modification by Rider and CSharpier. I've seen it a couple of times but it does not reproduce consistently.

java.lang.IllegalArgumentException: Someone is intentionally modifying the document while syncing from backend. Change: '
    internal static string Get([CallerFilePath] string? p = null) => p!;
}' -> '    internal static string Get([CallerFilePath] string? p = null) => p!;
}
' in 113
	at com.jetbrains.rider.document.RiderDocumentSynchronizer.verifyMayUpdateDocument(RiderDocumentSynchronizer.kt:28)
	at com.jetbrains.rdclient.document.FrontendDocumentSynchronizer.documentChanged(FrontendDocumentSynchronizer.kt:107)
	at com.intellij.openapi.editor.impl.DocumentImpl.changedUpdate(DocumentImpl.java:917)
	at com.intellij.openapi.editor.impl.DocumentImpl.updateText(DocumentImpl.java:821)
	at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:662)
	at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:599)
	at com.intellij.csharpier.FormattingService.lambda$format$0(FormattingService.java:64)
	at com.intellij.openapi.command.WriteCommandAction.lambda$runWriteCommandAction$4(WriteCommandAction.java:361)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$1(WriteCommandAction.java:150)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:947)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$2(WriteCommandAction.java:148)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:210)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:184)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.doRunWriteCommandAction(WriteCommandAction.java:157)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.run(WriteCommandAction.java:124)
	at com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction(WriteCommandAction.java:361)
	at com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction(WriteCommandAction.java:349)
	at com.intellij.csharpier.FormattingService.format(FormattingService.java:63)
	at com.intellij.csharpier.ReformatWithCSharpierOnSave.beforeDocumentSaving(ReformatWithCSharpierOnSave.java:35)
	at jdk.internal.reflect.GeneratedMethodAccessor239.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.multiCast(FileDocumentManagerImpl.java:185)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$new$0(FileDocumentManagerImpl.java:128)
	at com.sun.proxy.$Proxy24.beforeDocumentSaving(Unknown Source)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$doSaveDocumentInWriteAction$4(FileDocumentManagerImpl.java:407)
	at com.intellij.pom.core.impl.PomModelImpl.guardPsiModificationsIn(PomModelImpl.java:326)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.doSaveDocumentInWriteAction(FileDocumentManagerImpl.java:406)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$doSaveDocument$2(FileDocumentManagerImpl.java:367)
	at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:86)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:935)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:961)
	at com.intellij.openapi.application.WriteAction.run(WriteAction.java:85)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.doSaveDocument(FileDocumentManagerImpl.java:367)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveDocument(FileDocumentManagerImpl.java:318)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveDocument(FileDocumentManagerImpl.java:308)
	at com.jetbrains.rider.document.DocumentExKt.saveCorrespondingDocument(DocumentEx.kt:69)
	at com.jetbrains.rider.ideaInterop.vfs.actions.MoveAction.perform(MoveAction.kt:15)
	at com.jetbrains.rider.ideaInterop.vfs.actions.FromToAction$execute$2.run(FromToAction.kt:46)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:947)
	at com.jetbrains.rider.ideaInterop.vfs.actions.FromToAction.execute(FromToAction.kt:45)
	at com.jetbrains.rider.ideaInterop.vfs.VfsWriteOperationsHost.s(VfsWriteOperationsHost.kt:282)
	at com.jetbrains.rider.ideaInterop.vfs.VfsWriteOperationsHost.access$move(VfsWriteOperationsHost.kt:38)
	at com.jetbrains.rider.ideaInterop.vfs.VfsWriteOperationsHost$1$5.invoke(VfsWriteOperationsHost.kt:101)
	at com.jetbrains.rider.ideaInterop.vfs.VfsWriteOperationsHost$1$5.invoke(VfsWriteOperationsHost.kt:38)
	at com.jetbrains.rd.framework.IRdEndpoint$set$1.invoke(TaskInterfaces.kt:148)
	at com.jetbrains.rd.framework.IRdEndpoint$set$1.invoke(TaskInterfaces.kt:139)
	at com.jetbrains.rd.framework.impl.RdCall.onWireReceived(RdTask.kt:297)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2$2.invoke(MessageBroker.kt:56)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2$2.invoke(MessageBroker.kt:11)
	at com.jetbrains.rd.framework.impl.ProtocolContexts.readMessageContextAndInvoke(ProtocolContexts.kt:151)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2.invoke(MessageBroker.kt:55)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2.invoke(MessageBroker.kt:11)
	at com.jetbrains.rdclient.protocol.RdDispatcher.pumpProtocolQueue(RdDispatcher.kt:72)
	at com.jetbrains.rd.platform.protocol.SwitchingScheduler.pumpProtocolQueue(SwitchingScheduler.kt:19)
	at com.jetbrains.rd.platform.protocol.IRdDispatcherKt.pumpProtocolQueue(IRdDispatcher.kt:27)
	at com.jetbrains.rider.document.RiderTransactionsHost$1.invoke(RiderTransactionsHost.kt:22)
	at com.jetbrains.rider.document.RiderTransactionsHost$1.invoke(RiderTransactionsHost.kt:12)
	at com.jetbrains.rd.util.reactive.InterfacesKt$viewNotNull$1.invoke(Interfaces.kt:57)
	at com.jetbrains.rd.util.reactive.InterfacesKt$viewNotNull$1.invoke(Interfaces.kt)
	at com.jetbrains.rd.util.reactive.IPropertyBase$view$$inlined$let$lambda$1.invoke(Interfaces.kt:78)
	at com.jetbrains.rd.util.reactive.IPropertyBase$view$$inlined$let$lambda$1.invoke(Interfaces.kt:62)
	at com.jetbrains.rd.util.reactive.Signal.fire(Signal.kt:32)
	at com.jetbrains.rd.util.reactive.Property.setValue(Property.kt:20)
	at com.jetbrains.rd.util.reactive.Property.set(Property.kt:13)
	at com.jetbrains.rd.framework.impl.RdPropertyBase.onWireReceived(RdProperty.kt:76)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2$2.invoke(MessageBroker.kt:56)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2$2.invoke(MessageBroker.kt:11)
	at com.jetbrains.rd.framework.impl.ProtocolContexts.readMessageContextAndInvoke(ProtocolContexts.kt:151)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2.invoke(MessageBroker.kt:55)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2.invoke(MessageBroker.kt:11)
	at com.jetbrains.rdclient.protocol.RdDispatcher.pumpProtocolQueue(RdDispatcher.kt:72)
	at com.jetbrains.rd.platform.protocol.SwitchingScheduler.pumpProtocolQueue(SwitchingScheduler.kt:19)
	at com.jetbrains.rdclient.util.idea.ExtensionsKt.callSynchronously(Extensions.kt:140)
	at com.jetbrains.rdclient.util.idea.ExtensionsKt.callSynchronously$default(Extensions.kt:123)
	at com.jetbrains.rider.util.idea.ExtensionsKt.syncFromBackend(Extensions.kt:95)
	at com.jetbrains.rider.intentions.altEnter.ReSharperPopupModel.executeItem(ReSharperPopupModel.kt:135)
	at com.jetbrains.rider.intentions.altEnter.PopupModel$attachTo$2.invoke(PopupModel.kt:23)
	at com.jetbrains.rider.intentions.altEnter.PopupModel$attachTo$2.invoke(PopupModel.kt:9)
	at com.jetbrains.rd.util.reactive.Signal.fire(Signal.kt:32)
	at com.jetbrains.rider.services.popups.nova.impl.DefaultPopupViewModel$initViewModel$3.invoke(DefaultPopupViewModel.kt:77)
	at com.jetbrains.rider.services.popups.nova.impl.DefaultPopupViewModel$initViewModel$3.invoke(DefaultPopupViewModel.kt:16)
	at com.jetbrains.rd.util.reactive.Signal.fire(Signal.kt:32)
	at com.jetbrains.rider.services.popups.nova.impl.DefaultPopupListModel$executeSelectedItem$executeDelegate$1.invoke(DefaultPopupListModel.kt:137)
	at com.jetbrains.rider.services.popups.nova.impl.DefaultPopupListModel$executeSelectedItem$executeDelegate$1.invoke(DefaultPopupListModel.kt:15)
	at com.jetbrains.rider.services.popups.nova.ui.PopupListView$sam$java_lang_Runnable$0.run(PopupListView.kt)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
	at com.intellij.ui.popup.AbstractPopup.lambda$dispose$18(AbstractPopup.java:1508)
	at com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:101)
	at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.java:186)
	at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.java:140)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:175)
	at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.doWhenFocusSettlesDown(IdeFocusManagerImpl.java:36)
	at com.intellij.ui.popup.AbstractPopup.dispose(AbstractPopup.java:1505)
	at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:139)
	at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:169)
	at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217)
	at com.intellij.ui.popup.AbstractPopup.cancel(AbstractPopup.java:782)
	at com.jetbrains.rider.services.popups.nova.ui.PopupViewImpl.cancel(PopupViewImpl.kt:85)
	at com.intellij.ui.popup.AbstractPopup.cancel(AbstractPopup.java:730)
	at com.intellij.ui.popup.AbstractPopup.dispose(AbstractPopup.java:1454)
	at com.jetbrains.rider.services.popups.nova.ui.PopupViewImpl$2.invoke(PopupViewImpl.kt:61)
	at com.jetbrains.rider.services.popups.nova.ui.PopupViewImpl$2.invoke(PopupViewImpl.kt:35)
	at com.jetbrains.rd.util.lifetime.LifetimeDefinition.destruct(RLifetime.kt:298)
	at com.jetbrains.rd.util.lifetime.LifetimeDefinition.terminate(RLifetime.kt:279)
	at com.jetbrains.rd.util.lifetime.LifetimeDefinition.terminate$default(RLifetime.kt:253)
	at com.jetbrains.rider.services.popups.nova.ui.PopupViewHierarchy.F(PopupViewHierarchy.kt:155)
	at com.jetbrains.rider.services.popups.nova.ui.PopupViewHierarchy.closeAllViews(PopupViewHierarchy.kt:167)
	at com.jetbrains.rider.services.popups.nova.ui.PopupListView$executeSelectedItem$1.invoke(PopupListView.kt:284)
	at com.jetbrains.rider.services.popups.nova.ui.PopupListView$executeSelectedItem$1.invoke(PopupListView.kt:34)
	at com.jetbrains.rider.services.popups.nova.impl.DefaultPopupListModel.executeSelectedItem(DefaultPopupListModel.kt:144)
	at com.jetbrains.rider.services.popups.nova.ui.PopupListView.w(PopupListView.kt:278)
	at com.jetbrains.rider.services.popups.nova.ui.PopupListView.dispatchKeyEvent(PopupListView.kt:298)
	at com.jetbrains.rider.services.popups.nova.ui.PopupViewImpl.dispatch(PopupViewImpl.kt:148)
	at com.jetbrains.rider.services.popups.nova.ui.PopupViewHierarchy.w(PopupViewHierarchy.kt:101)
	at com.jetbrains.rider.services.popups.nova.ui.PopupViewHierarchy.dispatch(PopupViewHierarchy.kt:125)
	at com.intellij.ide.IdePopupManager.dispatch(IdePopupManager.java:101)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:724)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:498)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:188)
	at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
	at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
	at com.jetbrains.rider.services.popups.nova.impl.RiderModalPopupCookie$ModalContext.dispose(RiderModalPopupCookie.kt:63)
	at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:139)
	at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:169)
	at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217)
	at com.intellij.openapi.util.Disposer.dispose(Disposer.java:205)
	at com.jetbrains.rider.services.popups.nova.impl.RiderModalPopupCookie$Companion.using(RiderModalPopupCookie.kt:98)
	at com.jetbrains.rider.intentions.altEnter.RiderShowIntentionActionsHandler$Companion.d(RiderShowIntentionActionsHandler.kt:131)
	at com.jetbrains.rider.intentions.altEnter.RiderShowIntentionActionsHandler$Companion.access$showPopup(RiderShowIntentionActionsHandler.kt:42)
	at com.jetbrains.rider.intentions.altEnter.RiderShowIntentionActionsHandler$Companion$showAltEnterMenu$1$2.accept(RiderShowIntentionActionsHandler.kt:87)
	at com.jetbrains.rider.intentions.altEnter.RiderShowIntentionActionsHandler$Companion$showAltEnterMenu$1$2.accept(RiderShowIntentionActionsHandler.kt:42)
	at org.jetbrains.concurrency.AsyncPromise$onProcessed$1.accept(AsyncPromise.kt:103)
	at org.jetbrains.concurrency.AsyncPromise$onProcessed$1.accept(AsyncPromise.kt:16)
	at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
	at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)
	at org.jetbrains.concurrency.AsyncPromise.setResult(AsyncPromise.kt:149)
	at com.jetbrains.rider.intentions.altEnter.ReSharperBulbMenuModelFactory$processProtocolModel$4.invoke(ReSharperBulbMenuModelFactory.kt:141)
	at com.jetbrains.rider.intentions.altEnter.ReSharperBulbMenuModelFactory$processProtocolModel$4.invoke(ReSharperBulbMenuModelFactory.kt:33)
	at com.jetbrains.rd.util.reactive.BoolPropertyExKt$whenTrue$1.invoke(BoolPropertyEx.kt:12)
	at com.jetbrains.rd.util.reactive.BoolPropertyExKt$whenTrue$1.invoke(BoolPropertyEx.kt)
	at com.jetbrains.rd.util.reactive.IPropertyBase$view$$inlined$let$lambda$1.invoke(Interfaces.kt:78)
	at com.jetbrains.rd.util.reactive.IPropertyBase$view$$inlined$let$lambda$1.invoke(Interfaces.kt:62)
	at com.jetbrains.rd.util.reactive.Signal.fire(Signal.kt:32)
	at com.jetbrains.rd.util.reactive.OptProperty.set(Property.kt:40)
	at com.jetbrains.rd.framework.impl.RdPropertyBase.onWireReceived(RdProperty.kt:76)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2$2.invoke(MessageBroker.kt:56)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2$2.invoke(MessageBroker.kt:11)
	at com.jetbrains.rd.framework.impl.ProtocolContexts.readMessageContextAndInvoke(ProtocolContexts.kt:151)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2.invoke(MessageBroker.kt:55)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2.invoke(MessageBroker.kt:11)
	at com.jetbrains.rdclient.protocol.RdDispatcher.pumpProtocolQueue(RdDispatcher.kt:72)
	at com.jetbrains.rd.platform.protocol.SwitchingScheduler.pumpProtocolQueue(SwitchingScheduler.kt:19)
	at com.jetbrains.rd.platform.protocol.IRdDispatcherKt.pumpProtocolQueue(IRdDispatcher.kt:27)
	at com.jetbrains.rider.intentions.altEnter.ReSharperBulbMenuModelFactory.X(ReSharperBulbMenuModelFactory.kt:144)
	at com.jetbrains.rider.intentions.altEnter.ReSharperBulbMenuModelFactory.access$processProtocolModel(ReSharperBulbMenuModelFactory.kt:33)
	at com.jetbrains.rider.intentions.altEnter.ReSharperBulbMenuModelFactory$create$5.invoke(ReSharperBulbMenuModelFactory.kt:75)
	at com.jetbrains.rider.intentions.altEnter.ReSharperBulbMenuModelFactory$create$5.invoke(ReSharperBulbMenuModelFactory.kt:33)
	at com.jetbrains.rd.util.reactive.SourceExKt$adviseUntil$1$1.invoke(SourceEx.kt:27)
	at com.jetbrains.rd.util.reactive.SourceExKt$adviseUntil$1$1.invoke(SourceEx.kt)
	at com.jetbrains.rd.util.reactive.Signal.fire(Signal.kt:32)
	at com.jetbrains.rd.util.reactive.Property.setValue(Property.kt:20)
	at com.jetbrains.rd.util.reactive.Property.set(Property.kt:13)
	at com.jetbrains.rd.framework.impl.RdPropertyBase.onWireReceived(RdProperty.kt:76)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2$2.invoke(MessageBroker.kt:56)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2$2.invoke(MessageBroker.kt:11)
	at com.jetbrains.rd.framework.impl.ProtocolContexts.readMessageContextAndInvoke(ProtocolContexts.kt:151)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2.invoke(MessageBroker.kt:55)
	at com.jetbrains.rd.framework.MessageBroker$invoke$2.invoke(MessageBroker.kt:11)
	at com.jetbrains.rdclient.protocol.RdDispatcher.flushAll(RdDispatcher.kt:97)
	at com.jetbrains.rdclient.protocol.RdDispatcher.access$flushAll(RdDispatcher.kt:18)
	at com.jetbrains.rdclient.protocol.RdDispatcher$flushAllRunnable$1.run(RdDispatcher.kt:23)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:348)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
@belav belav added area:rider type:bug Something isn't working labels Jan 26, 2022
@belav
Copy link
Owner

belav commented Jan 26, 2022

Possibly related, I got this while changing branches using the command line. Using 0.13.0 and the beta2

Exception while committing com.intellij.psi.SingleRootFileViewProvider{vFile=file://C:/projects/insite-commerce/Legacy/Automation/Insite.Automated.Core/Capturer.cs, vFileId=158844, content=VirtualFileContent{size=8286}, eventSystemEnabled=true}, eventSystemEnabled=false

com.intellij.util.IncorrectOperationException: Must not modify PSI inside save listener
	at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:91)
	at com.intellij.psi.impl.DiffLog.lambda$doActualPsiChange$0(DiffLog.java:244)
	at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.lambda$performActionWithFormatterDisabled$4(CodeStyleManagerImpl.java:459)
	at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:128)
	at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:487)
	at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:458)
	at com.intellij.psi.impl.DiffLog.doActualPsiChange(DiffLog.java:232)
	at com.intellij.psi.impl.DocumentCommitThread.lambda$doCommit$5(DocumentCommitThread.java:306)
	at com.intellij.psi.impl.PsiDocumentManagerBase.commitToExistingPsi(PsiDocumentManagerBase.java:420)
	at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$finishCommitInWriteAction$4(PsiDocumentManagerBase.java:394)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeInNonCancelableSection(CoreProgressManager.java:237)
	at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$finishCommitInWriteAction$5(PsiDocumentManagerBase.java:389)
	at com.intellij.psi.impl.PsiDocumentManagerBase.executeInsideCommit(PsiDocumentManagerBase.java:505)
	at com.intellij.psi.impl.PsiDocumentManagerBase.finishCommitInWriteAction(PsiDocumentManagerBase.java:387)
	at com.intellij.psi.impl.PsiDocumentManagerImpl.finishCommitInWriteAction(PsiDocumentManagerImpl.java:124)
	at com.intellij.psi.impl.PsiDocumentManagerBase.finishCommit(PsiDocumentManagerBase.java:348)
	at com.intellij.psi.impl.DocumentCommitThread.lambda$commitUnderProgress$2(DocumentCommitThread.java:146)
	at com.intellij.psi.impl.DocumentCommitThread.commitSynchronously(DocumentCommitThread.java:105)
	at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$doCommit$8(PsiDocumentManagerBase.java:490)
	at com.intellij.psi.impl.PsiDocumentManagerBase.executeInsideCommit(PsiDocumentManagerBase.java:505)
	at com.intellij.psi.impl.PsiDocumentManagerBase.doCommit(PsiDocumentManagerBase.java:490)
	at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$doCommit$7(PsiDocumentManagerBase.java:479)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:947)
	at com.intellij.psi.impl.PsiDocumentManagerBase.doCommit(PsiDocumentManagerBase.java:479)
	at com.intellij.psi.impl.PsiDocumentManagerBase.commitDocument(PsiDocumentManagerBase.java:328)
	at com.intellij.codeInsight.template.impl.TemplateState.recalcSegment(TemplateState.java:715)
	at com.intellij.codeInsight.template.impl.TemplateState.lambda$calcResults$5(TemplateState.java:610)
	at com.intellij.openapi.project.DumbService.withAlternativeResolveEnabled(DumbService.java:353)
	at com.intellij.codeInsight.template.impl.TemplateState.lambda$calcResults$6(TemplateState.java:609)
	at com.intellij.openapi.command.WriteCommandAction.lambda$runWriteCommandAction$4(WriteCommandAction.java:361)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$1(WriteCommandAction.java:150)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:947)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$2(WriteCommandAction.java:148)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:210)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:184)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.doRunWriteCommandAction(WriteCommandAction.java:157)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.run(WriteCommandAction.java:124)
	at com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction(WriteCommandAction.java:361)
	at com.intellij.codeInsight.template.impl.TemplateState.calcResults(TemplateState.java:592)
	at com.intellij.codeInsight.template.impl.TemplateState.afterChangedUpdate(TemplateState.java:446)
	at com.intellij.codeInsight.template.impl.TemplateState$3.lambda$beforeCommandFinished$0(TemplateState.java:147)
	at com.intellij.codeInsight.lookup.LookupUtil.performGuardedChange(LookupUtil.kt:107)
	at com.intellij.codeInsight.template.impl.TemplateState$3.beforeCommandFinished(TemplateState.java:147)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:620)
	at com.intellij.util.messages.impl.MessageBusImpl.access$300(MessageBusImpl.java:33)
	at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.executeOrAddToQueue(MessageBusImpl.java:208)
	at com.intellij.util.messages.impl.CompositeMessageBus$ToDirectChildrenMessagePublisher.publish(CompositeMessageBus.java:125)
	at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:166)
	at com.sun.proxy.$Proxy73.beforeCommandFinished(Unknown Source)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.fireCommandFinished(CoreCommandProcessor.java:274)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.finishCommand(CoreCommandProcessor.java:259)
	at com.intellij.openapi.command.impl.CommandProcessorImpl.finishCommand(CommandProcessorImpl.java:34)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:225)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:184)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.doRunWriteCommandAction(WriteCommandAction.java:157)
	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.run(WriteCommandAction.java:124)
	at com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction(WriteCommandAction.java:361)
	at com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction(WriteCommandAction.java:349)
	at com.intellij.csharpier.FormattingService.format(FormattingService.java:63)
	at com.intellij.csharpier.ReformatWithCSharpierOnSave.beforeDocumentSaving(ReformatWithCSharpierOnSave.java:35)
	at jdk.internal.reflect.GeneratedMethodAccessor227.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.multiCast(FileDocumentManagerImpl.java:185)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$new$0(FileDocumentManagerImpl.java:128)
	at com.sun.proxy.$Proxy21.beforeDocumentSaving(Unknown Source)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$doSaveDocumentInWriteAction$4(FileDocumentManagerImpl.java:407)
	at com.intellij.pom.core.impl.PomModelImpl.guardPsiModificationsIn(PomModelImpl.java:326)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.doSaveDocumentInWriteAction(FileDocumentManagerImpl.java:406)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$doSaveDocument$2(FileDocumentManagerImpl.java:367)
	at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:86)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:935)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:961)
	at com.intellij.openapi.application.WriteAction.run(WriteAction.java:85)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.doSaveDocument(FileDocumentManagerImpl.java:367)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveDocuments(FileDocumentManagerImpl.java:287)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveAllDocuments(FileDocumentManagerImpl.java:262)
	at com.intellij.configurationStore.SaveAndSyncHandlerImpl$addListeners$3.onFrameDeactivated(SaveAndSyncHandlerImpl.kt:149)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:642)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:620)
	at com.intellij.util.messages.impl.MessageBusImpl.deliverMessage(MessageBusImpl.java:417)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:390)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:372)
	at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:33)
	at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:179)
	at com.sun.proxy.$Proxy33.onFrameDeactivated(Unknown Source)
	at com.intellij.ide.FrameStateManagerImpl$2.applicationDeactivated(FrameStateManagerImpl.java:57)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:620)
	at com.intellij.util.messages.impl.MessageBusImpl.deliverMessage(MessageBusImpl.java:417)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:390)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:372)
	at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:33)
	at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:179)
	at com.sun.proxy.$Proxy46.applicationDeactivated(Unknown Source)
	at com.intellij.ide.ApplicationActivationStateManager.updateState(ApplicationActivationStateManager.java:61)
	at com.intellij.ide.IdeEventQueue.processAppActivationEvent(IdeEventQueue.java:851)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:732)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:498)
	at java.desktop/java.awt.SentEvent.dispatch(SentEvent.java:70)
	at java.desktop/java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent.dispatch(DefaultKeyboardFocusManager.java:254)
	at java.desktop/java.awt.DefaultKeyboardFocusManager.sendMessage(DefaultKeyboardFocusManager.java:281)
	at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:825)
	at com.intellij.ide.IdeKeyboardFocusManager.dispatchEvent(IdeKeyboardFocusManager.java:42)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4910)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2790)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:498)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

@belav
Copy link
Owner

belav commented Jan 28, 2022

I was able to fairly reliably reproduce the Someone is intentionally modifying the document while syncing from backend. issue. When testing the development plugin, I instead got warnings about Client text differs from backend text. using the same steps.

I have a new beta3 that I believe solves the issue. https://github.com/belav/csharpier/releases/tag/rider-1.2.0-beta3

I haven't yet reproduced the issue that I saw with Must not modify PSI inside save listener so I am not sure if the new beta3 solves it as well.

@shocklateboy92
Copy link
Collaborator

Uh... I haven't looked too deep into how the Rider plugin works, but to clarify: when told to format the plugin uses csharpier to modify the active buffer, right? (not the file on disk).

@belav
Copy link
Owner

belav commented Jan 28, 2022

Correct, it makes use of Document
And wraps the actual writing replaceString in WriteCommandAction.runWriteCommandAction
I just realized this morning that beta3 doesn't seem to work at all with format on save. I had a leftover file watcher running csharpier when a file was saved.

@belav
Copy link
Owner

belav commented Jan 31, 2022

I ran into a few roadblocks, and had to completely change the approach to how to format files on save, but have a new prerelease that solves the problem.
https://github.com/belav/csharpier/releases/tag/rider-1.2.1-beta1

I submitted 1.2.0 to jetbrains last friday because it fixed a number of other issues. I'll submit 1.2.1 sometime this week after some more testing.

Some of the technical details, so that I have them recorded somewhere.
Using a FileDocumentListener, there was a race condition where the rider backend and csharpier were both formatting a file at the same time.
Using beforeAllDocumentsSaving allowed csharpier to format files without conflicting with the rider backend in some cases. The case where it didn't work - the save document action. beforeAllDocumentsSaving was never triggered. If rider had ctrl-s bound to "Save all files" then it worked. I personally have ctrl-s bound to "Save all files" in my dev version of rider, but "Save File" bound in my installed version of rider. Which lead to some confusion when things didn't work consistently.
ActionsOnSaveFileDocumentManagerListener.ActionOnSave works off beforeAllDocumentsSaving behind the scenes so has the same problem.
Using beforeDocumentSaving but invoking the formatting later, csharpier didn't conflict with rider, but csharpier did end up formatting a file twice each time you saved it.
Using AnActionListener and responding to the SaveDocumentAction and SaveAllAction was the solution that works.

@belav belav closed this as completed in #576 Feb 5, 2022
belav added a commit that referenced this issue Feb 5, 2022
* Switching to ActionsOnSaveFileDocumentManagerListener.ActionOnSave

Possible fix for #573

* Get format on save to actually work

* Who knows, trying everything

* Little things

* Little tweak

* This is the way

* Implementing AnActionListener to handle format on save

* Self code review
@aaron-manning
Copy link

This still seems to happen on the latest version of Rider if you use a macro that does a code cleanup and then cSharpier reformat

@MonstraG
Copy link

MonstraG commented Sep 2, 2024

Just had this happen on csharpier 1.8.2. with following exception:

java.lang.IllegalArgumentException: Someone is intentionally modifying the document while syncing from backend. Change: '
{
	
' -> ' { ' in 75
	at com.jetbrains.rider.document.RiderDocumentSynchronizer.verifyMayUpdateDocument(RiderDocumentSynchronizer.kt:31)
	at com.jetbrains.rider.document.TextBufferDocumentSynchronizer.documentChanged(TextBufferDocumentSynchronizer.kt:108)
	at com.intellij.openapi.editor.impl.DocumentImpl.lambda$changedUpdate$1(DocumentImpl.java:924)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rider type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants