Debugger () { Throwable lastException = null; for (int i = 0; i < 10; i++) { if (myProcess.isProcessTerminated()) return null; try { final Debugger realClient = EDTGuard.create(new RemoteDebuggerClient(myPort, myAccessToken), myProcess); myProcess.notifyTextAvailable("Connected to XSLT debugger on port " + myPort + "\n", ProcessOutputTypes.SYSTEM); return realClient; } catch (ConnectException e) { lastException = e; try { Thread.sleep(500); } catch (InterruptedException e1) { break; } } catch (NotBoundException e) { lastException = e; try { Thread.sleep(200); } catch (InterruptedException e1) { break; } } catch (IOException e) { lastException = e; break; } } Logger.getInstance(getClass().getName()).info("Could not connect to debugger", lastException); if (lastException.getMessage() != null) { myProcess.notifyTextAvailable("Connection error: " + lastException.getMessage() + "\n", ProcessOutputTypes.SYSTEM); } return null; }