IDEA-140186 10 seconds IDE hang if debug process hanged
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Fri, 15 May 2015 10:21:50 +0000 (13:21 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Fri, 15 May 2015 10:21:50 +0000 (13:21 +0300)
java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java

index 9b9a45c70c4d26b85f4f20dad42d742ee00489c4..e09ab0958286904883bbafea8a7e88c73383ddc0 100644 (file)
@@ -40,6 +40,7 @@ import com.intellij.openapi.editor.colors.EditorColorsListener;
 import com.intellij.openapi.editor.colors.EditorColorsManager;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.JavaSdk;
 import com.intellij.openapi.projectRoots.JavaSdkVersion;
@@ -60,6 +61,7 @@ import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
 import java.io.File;
 import java.util.*;
 import java.util.jar.Attributes;
@@ -280,7 +282,18 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
             // wait at most 10 seconds: the problem is that debugProcess.stop() can hang if there are troubles in the debuggee
             // if processWillTerminate() is called from AWT thread debugProcess.waitFor() will block it and the whole app will hang
             if (!DebuggerManagerThreadImpl.isManagerThread()) {
-              debugProcess.waitFor(10000);
+              if (SwingUtilities.isEventDispatchThread()) {
+                ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
+                  @Override
+                  public void run() {
+                    ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
+                    debugProcess.waitFor(10000);
+                  }
+                }, "Waiting For Debugger Response", false, debugProcess.getProject());
+              }
+              else {
+                debugProcess.waitFor(10000);
+              }
             }
           }
         }