Access is allowed from event dispatch thread only

Answered

I am currently facing this exception on CLion when I run my plugin with a sample rust project, however, this exception does not come through when the project size is small.

I have tested my extension with pycharm, goland, intellij IDEA ultimate and never seen this. This exception also does not happen if I debug my plugin by setting the platform to CL. The method where the exception starts is just using com.intellij.openapi.ui.DialogBuilder to create a dialog.

Reading https://plugins.jetbrains.com/docs/intellij/general-threading-rules.html?from=jetbrains.org I can't tell which part of my code should go in invokelater()? Not sure what is the correct way to deal with this.


com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: EventQueue.isDispatchThread()=false Current thread: Thread[ApplicationImpl pooled thread 9,4,main] 980076167 SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 1559461439 at com.intellij.openapi.application.impl.ApplicationImpl.throwThreadAccessException(ApplicationImpl.java:1110) at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:1093) at com.intellij.ide.impl.DataManagerImpl.getDataContext(DataManagerImpl.java:242) at com.intellij.ide.impl.DataManagerImpl.getDataContext(DataManagerImpl.java:273) at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.<init>(DialogWrapperPeerImpl.java:85) at com.intellij.openapi.ui.impl.DialogWrapperPeerFactoryImpl.createPeer(DialogWrapperPeerFactoryImpl.java:25) at com.jetbrains.rdserver.ui.dialogs.BackendDialogWrapperPeerFactory.createPeer(BackendDialogWrapperPeerFactory.kt:53) at com.intellij.openapi.ui.DialogWrapper.createPeer(DialogWrapper.java:857) at com.intellij.openapi.ui.DialogWrapper.<init>(DialogWrapper.java:228) at com.intellij.openapi.ui.DialogWrapper.<init>(DialogWrapper.java:220) at com.intellij.openapi.ui.DialogWrapper.<init>(DialogWrapper.java:213) at com.intellij.openapi.ui.DialogWrapper.<init>(DialogWrapper.java:209) at com.intellij.openapi.ui.DialogBuilder$MyDialogWrapper.<init>(DialogBuilder.java:346) at com.intellij.openapi.ui.DialogBuilder.<init>(DialogBuilder.java:55) at com.intellij.openapi.ui.DialogBuilder.<init>(DialogBuilder.java:65) at com.metalbear.mirrord.MirrordDialogBuilder.getDialogBuilder(MirrordDialogBuilder.kt:71) at com.metalbear.mirrord.MirrordListener.processStarting(MirrordListener.kt:46) at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:649) at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:625) at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:399) at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:378) at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1) at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:437) at jdk.proxy2/jdk.proxy2.$Proxy188.processStarting(Unknown Source) at org.rust.cargo.runconfig.buildtool.UtilsKt.notifyProcessStarting(Utils.kt:33) at org.rust.cargo.runconfig.buildtool.CargoBuildManager.execute$lambda-5(CargoBuildManager.kt:191) at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:297) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699) at java.base/java.lang.Thread.run(Thread.java:833)

3 comments
Comment actions Permalink

You're invoking a dialog directly from your MirrordListener. What does it extend and what's the use case?

0
Comment actions Permalink

Hi, thanks for the response.

MirrordListener is extending ExecutionListener and prompts a user to select some configuration before the start of the run process.

Here's the actual source if that helps:https://github.com/metalbear-co/mirrord/blob/main/intellij-ext/src/main/kotlin/com/metalbear/mirrord/MirrordListener.kt

0

Please sign in to leave a comment.