google-java-format icon indicating copy to clipboard operation
google-java-format copied to clipboard

Exception from the plugin while I was typing

Open Alos opened this issue 4 years ago • 2 comments

While I was typing IntelliJ showed a window with the following error:

2021-06-18 15:48:09,626 [18722893]  ERROR - plication.TransactionGuardImpl - Write-unsafe context! Model changes are allowed from write-safe contexts only. Please ensure you're using invokeLater/invokeAndWait with a correct modality state (not "any"). See TransactionGuard documentation for details.
  current modality=ModalityState:{[Resolving reference... 1489521932: running=false; canceled=false], [Resolving reference... 1026543882: running=false; canceled=false]}
java.lang.Throwable: Write-unsafe context! Model changes are allowed from write-safe contexts only. Please ensure you're using invokeLater/invokeAndWait with a correct modality state (not "any"). See TransactionGuard documentation for details.
  current modality=ModalityState:{[Resolving reference... 1489521932: running=false; canceled=false], [Resolving reference... 1026543882: running=false; canceled=false]}
        at com.intellij.openapi.diagnostic.Logger.error(Logger.java:161)
        at com.intellij.openapi.application.TransactionGuardImpl.assertWriteActionAllowed(TransactionGuardImpl.java:144)
        at com.intellij.psi.impl.PsiDocumentManagerBase.commitDocument(PsiDocumentManagerBase.java:326)
        at com.intellij.codeInsight.editorActions.SelectWordHandler.doExecute(SelectWordHandler.java:59)
        at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:202)
        at com.intellij.openapi.editor.actions.SelectWordAtCaretAction$Handler.doExecute(SelectWordAtCaretAction.java:89)
        at com.intellij.openapi.editor.actionSystem.DynamicEditorActionHandler.doExecute(DynamicEditorActionHandler.java:52)
        at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:202)
        at com.intellij.openapi.editor.impl.CaretImpl.lambda$selectWordAtCaret$9(CaretImpl.java:1273)
        at com.intellij.openapi.editor.impl.CaretModelImpl.doWithCaretMerging(CaretModelImpl.java:421)
        at com.intellij.openapi.editor.impl.CaretImpl.selectWordAtCaret(CaretImpl.java:1258)
        at com.intellij.openapi.editor.SelectionModel.selectWordAtCaret(SelectionModel.java:251)
        at com.intellij.openapi.editor.impl.EditorImpl.selectWordAtCaret(EditorImpl.java:4204)
        at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.processMousePressed(EditorImpl.java:4118)
        at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.lambda$runMousePressedCommand$0(EditorImpl.java:3867)
        at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:216)
        at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:172)
        at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.runMousePressedCommand(EditorImpl.java:3872)
        at com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.mousePressed(EditorImpl.java:3784)
        at java.desktop/java.awt.Component.processMouseEvent(Component.java:6649)
        at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
        at java.desktop/java.awt.Component.processEvent(Component.java:6417)
        at java.desktop/java.awt.Container.processEvent(Container.java:2263)
        at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4859)
        at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
        at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4544)
        at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
        at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2784)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4859)
        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)

Using:

IntelliJ IDEA 2021.1 (Ultimate Edition)
Build #IU-211.6693.111, built on April 6, 2021
Runtime version: 11.0.10+9-b1341.35 x86_64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
macOS 11.4
GC: ParNew, ConcurrentMarkSweep
Memory: 5036M
Cores: 12
Registry: ide.index.image.max.size=0, caches.indexerThreadsCount=24
Non-Bundled Plugins: google-java-format (1.9.0.1)

Alos avatar Jun 18 '21 23:06 Alos

cc @plumpy

@Alos, the stack trace doesn't mention google-java-format, are you sure it's related to the plugin? Do you have a repro?

cushon avatar Jun 18 '21 23:06 cushon

Yes, the error was generated from the plugin according to IntelliJ:

Screen Shot 2021-06-18 at 3 49 17 PM

I can't reproduce it on command, its just happened twice. I'll update the bug if I can get it to reproduce consistently.

Alos avatar Jun 21 '21 16:06 Alos

This should be fixed in 1.16.0.0, which uses a newer officially-supported formatter API.

plumpy avatar Mar 03 '23 20:03 plumpy