From e4ce1baa23ba3142fc51911ef39b093ea9d49242 Mon Sep 17 00:00:00 2001 From: Demyan Kimitsa Date: Sun, 3 Mar 2024 23:46:50 +0200 Subject: [PATCH] * Idea Plugin: fix for IllegalStateException reported in review (#771) Note: from the log it seems like the test is being running in WSL on Windows machine. So it should not affect Mac users > After performing an additional automated check, we have found that this plugin version causes the freeze on the IDE startup: ``` java.lang.IllegalStateException: This method is forbidden on EDT because it does not pump the event queue. Switch to a BGT, or use com.intellij.openapi.progress.TasksKt.runWithModalProgressBlocking. at com.intellij.openapi.progress.CoroutinesKt.assertBackgroundThreadOrWriteAction(coroutines.kt:448) at com.intellij.openapi.progress.CoroutinesKt.runBlockingCancellable(coroutines.kt:125) at com.intellij.openapi.progress.CoroutinesKt.runBlockingCancellable(coroutines.kt:121) at com.intellij.execution.wsl.WslIjentUtil.fetchLoginShellEnv(WslIjentUtil.kt:34) at com.intellij.execution.wsl.WSLDistribution.getEnvironmentVariable(WSLDistribution.java:794) at com.intellij.openapi.projectRoots.impl.JavaHomeFinderWsl$WslSystemInfoProvider.getEnvironmentVariable(JavaHomeFinderWsl.java:59) at com.intellij.openapi.projectRoots.impl.JavaHomeFinderBasic.findInPATH(JavaHomeFinderBasic.java:122) at com.intellij.openapi.projectRoots.impl.JavaHomeFinderBasic.findExistingJdks(JavaHomeFinderBasic.java:102) at com.intellij.openapi.projectRoots.impl.JavaHomeFinderWindows._init_$lambda$0(JavaHomeFinderWindows.kt:71) at com.intellij.openapi.projectRoots.impl.JavaHomeFinderBasic.findExistingJdks(JavaHomeFinderBasic.java:102) at com.intellij.openapi.projectRoots.impl.JavaHomeFinder.suggestHomePaths(JavaHomeFinder.java:73) at com.intellij.openapi.projectRoots.impl.JavaHomeFinder.suggestHomePaths(JavaHomeFinder.java:61) at com.intellij.openapi.projectRoots.impl.JavaSdkImpl.suggestHomePaths(JavaSdkImpl.java:196) at org.robovm.idea.components.setupwizard.JdkSetupDialog.(JdkSetupDialog.java:43) at org.robovm.idea.components.RoboVmApplicationComponent.displaySetupWizard(RoboVmApplicationComponent.java:65) at org.robovm.idea.components.RoboVmApplicationComponent.initComponent(RoboVmApplicationComponent.java:47) Today ``` --- .../robovm/idea/components/setupwizard/JdkSetupDialog.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/idea/src/main/java/org/robovm/idea/components/setupwizard/JdkSetupDialog.java b/plugins/idea/src/main/java/org/robovm/idea/components/setupwizard/JdkSetupDialog.java index 07d93ba76..2a104f447 100755 --- a/plugins/idea/src/main/java/org/robovm/idea/components/setupwizard/JdkSetupDialog.java +++ b/plugins/idea/src/main/java/org/robovm/idea/components/setupwizard/JdkSetupDialog.java @@ -12,6 +12,7 @@ import com.intellij.openapi.projectRoots.JdkUtil; import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; @@ -22,6 +23,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Arrays; +import java.util.Collection; import java.util.List; public class JdkSetupDialog extends JDialog { @@ -40,7 +42,10 @@ public JdkSetupDialog() { setTitle("RoboVM Setup"); infoText.setText("RoboVM requires Java Development Kit (JDK) 8.0 or higher.

Please specify the location of your JDK."); - for (String jdkLocation : JavaSdk.getInstance().suggestHomePaths()) { + final Collection existingSdks = ApplicationManager.getApplication().runWriteAction( + (Computable>) () -> JavaSdk.getInstance().suggestHomePaths() + ); + for (String jdkLocation : existingSdks) { jdkHome.setText(jdkLocation); break; }