Skip to content

Commit

Permalink
fix: wait for output reading to complete before parsing version (#19921
Browse files Browse the repository at this point in the history
…) (#19931)

NodeInstall.getVersion currently does not block waiting for STDOUT and STDERR
to be read completely. This causes random failure during node
installation because of forcing an empty version.
This change waits for future to complete before parsing the version
value.

Co-authored-by: Marco Collovati <marco@vaadin.com>
  • Loading branch information
vaadin-bot and mcollovati authored Sep 11, 2024
1 parent 4a4f695 commit e44fe22
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -559,8 +562,14 @@ private static FrontendVersion getVersion(String tool,
throw new IOException("Process exited with non 0 exit code. ("
+ exitCode + ")");
}
return FrontendUtils.parseFrontendVersion(
streamConsumer.getNow(new Pair<>("", "")).getFirst());
String version;
try {
version = streamConsumer.get(1, TimeUnit.SECONDS).getFirst();
} catch (ExecutionException | TimeoutException e) {
getLogger().debug("Cannot read {} version", tool, e);
version = "";
}
return FrontendUtils.parseFrontendVersion(version);
} catch (InterruptedException | IOException e) {
throw new InstallationException(String.format(
"Unable to detect version of %s. %s", tool,
Expand Down

0 comments on commit e44fe22

Please sign in to comment.