From 625d59f13cf8ba1d20bc0fc5a66ac42c6b08fd4f Mon Sep 17 00:00:00 2001 From: tanjh Date: Fri, 1 Sep 2023 16:40:26 +0800 Subject: [PATCH] FIX BUG: the process will stall if the output buffer fill up. it will make the generate test task terminate with timeout. --- .../evosuite/continuous/job/JobHandler.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/master/src/main/java/org/evosuite/continuous/job/JobHandler.java b/master/src/main/java/org/evosuite/continuous/job/JobHandler.java index 5ced3282f6..53c7e7fbdb 100755 --- a/master/src/main/java/org/evosuite/continuous/job/JobHandler.java +++ b/master/src/main/java/org/evosuite/continuous/job/JobHandler.java @@ -138,6 +138,7 @@ public void run() { } process = builder.start(); latestProcess = process; + handleProcessOutput(process); int exitCode = process.waitFor(); //no need to have timeout here, as it is handled by the scheduler/executor @@ -169,6 +170,28 @@ public void run() { } } } + private final void handleProcessOutput(final Process process) { + Thread reader = new Thread() { + @Override + public void run() { + try { + BufferedReader in = new BufferedReader( + new InputStreamReader(process.getInputStream())); + String line = ""; + while (!this.isInterrupted()) { + line = in.readLine(); + if (line != null && !line.isEmpty()) { + logger.info(line); + } + } + } catch (Exception e) { + logger.error("Exception while reading spawn process output: " + e); + } + } + }; + reader.start(); + logger.debug("Started thread to read spawn process output"); + } /** * Print process console output if it died, as its logs on disks might not