From 5eeded86c246c6944266a982a476d9ecd2501b47 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Fri, 22 Oct 2021 14:38:58 -0400 Subject: [PATCH] Better Windows build-in DFU #3338 Sometimes process has already finished but we still want to read output, so give it extra half a second --- .../src/main/java/com/rusefi/maintenance/ExecHelper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/java_console/ui/src/main/java/com/rusefi/maintenance/ExecHelper.java b/java_console/ui/src/main/java/com/rusefi/maintenance/ExecHelper.java index b5150150e2..fbd201ac65 100644 --- a/java_console/ui/src/main/java/com/rusefi/maintenance/ExecHelper.java +++ b/java_console/ui/src/main/java/com/rusefi/maintenance/ExecHelper.java @@ -1,5 +1,6 @@ package com.rusefi.maintenance; +import com.devexperts.util.TimeUtil; import com.rusefi.SimulatorExecHelper; import com.rusefi.ui.StatusConsumer; import org.jetbrains.annotations.NotNull; @@ -28,12 +29,18 @@ public class ExecHelper { final Thread t = new Thread(() -> { try { BufferedReader bis = new BufferedReader(new InputStreamReader(stream)); - while (isRunning(p)) { + /* + * Sometimes process has already finished but we still want to read output, so give it extra half a second + * TODO: are we supposed to just NOT check process status and just wait for 'null' from readLine? + */ + long wasRunningTime = System.currentTimeMillis(); + while (isRunning(p) || (System.currentTimeMillis() - wasRunningTime) < 0.5 * TimeUtil.SECOND) { String line = bis.readLine(); if (line == null) break; wnd.appendMsg(line); buffer.append(line); + wasRunningTime = System.currentTimeMillis(); } } catch (IOException e) { wnd.appendMsg("Stream " + e);