From 10eb4af3be6ad8637737f1a1034f06f91c3b97bc Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Tue, 8 Nov 2016 13:49:54 -0500 Subject: [PATCH] more error handling and logging to sort out #4735 --- java/src/processing/mode/java/runner/Runner.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/java/src/processing/mode/java/runner/Runner.java b/java/src/processing/mode/java/runner/Runner.java index be8845a47..871020e72 100644 --- a/java/src/processing/mode/java/runner/Runner.java +++ b/java/src/processing/mode/java/runner/Runner.java @@ -33,6 +33,7 @@ import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Point; import java.io.*; +import java.net.ConnectException; import java.util.*; import com.sun.jdi.*; @@ -220,21 +221,29 @@ public class Runner implements MessageConsumer { // while (!available) { while (true) { try { + Messages.log(getClass().getName() + " attempting to attach to VM"); vm = connector.attach(arguments); // vm = connector.attach(arguments); if (vm != null) { + Messages.log(getClass().getName() + " attached to the VM"); // generateTrace(); // available = true; return true; } - } catch (IOException e) { + } catch (ConnectException ce) { + // This will fire ConnectException (socket not available) until + // the VM finishes starting up and opens its socket for us. + Messages.log(getClass().getName() + " socket for VM not ready"); // System.out.println("waiting"); // e.printStackTrace(); try { Thread.sleep(100); - } catch (InterruptedException e1) { - e1.printStackTrace(sketchErr); + } catch (InterruptedException ie) { + Messages.loge(getClass().getName() + " interrupted", ie); +// ie.printStackTrace(sketchErr); } + } catch (IOException e) { + Messages.loge(getClass().getName() + " while attaching to VM", e); } } // } catch (IOException exc) {