From 686b7338dc92b371b866c6746279074e1ceae05b Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Wed, 28 Apr 2021 13:00:29 +0200 Subject: [PATCH] further logging --- cobigen-eclipse/cobigen-eclipse/.classpath | 2 +- .../api/externalprocess/ExternalProcess.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cobigen-eclipse/cobigen-eclipse/.classpath b/cobigen-eclipse/cobigen-eclipse/.classpath index 3491647d65..975c88222b 100644 --- a/cobigen-eclipse/cobigen-eclipse/.classpath +++ b/cobigen-eclipse/cobigen-eclipse/.classpath @@ -11,7 +11,7 @@ - + diff --git a/cobigen/core-externalprocess-api/src/main/java/com/devonfw/cobigen/api/externalprocess/ExternalProcess.java b/cobigen/core-externalprocess-api/src/main/java/com/devonfw/cobigen/api/externalprocess/ExternalProcess.java index 1fa00e597e..e367ab158f 100644 --- a/cobigen/core-externalprocess-api/src/main/java/com/devonfw/cobigen/api/externalprocess/ExternalProcess.java +++ b/cobigen/core-externalprocess-api/src/main/java/com/devonfw/cobigen/api/externalprocess/ExternalProcess.java @@ -66,7 +66,7 @@ public class ExternalProcess { private final String serverVersion; /** Port used for connecting to the server */ - public int port = 5000; + private int port = 5000; /** Host name of the server, by default is localhost */ private String hostName = "localhost"; @@ -256,13 +256,21 @@ private boolean startServer(int currentTry) { LOG.info("Waiting process to be alive for {}s", 100 * retry / 1000d); } if (retry > 50) { + LOG.error("Server could not be started at port {}", port); return false; } + + LOG.info("Server started at port {}", port); + return true; } catch (Throwable e) { BindException bindException = ExceptionUtil.getCause(e, BindException.class); ConnectException connectException = ExceptionUtil.getCause(e, ConnectException.class); if (bindException != null || connectException != null) { - process.getProcess().destroyForcibly(); + try { + process.getProcess().destroyForcibly().waitFor(); + } catch (InterruptedException e1) { + LOG.error("Interrupted wait for process termination to complete", e1); + } int newPort = aquireNewPort(); LOG.debug("Port {} already in use, trying port {}", port, newPort); port = newPort; @@ -270,9 +278,6 @@ private boolean startServer(int currentTry) { } throw new CobiGenRuntimeException("Unable to start the exe/server", e); } - - LOG.info("Server started at port {}", port); - return true; } /**