Skip to content

Commit

Permalink
Refs #6488 Fix deadlock while waiting for command. (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Gasco authored and raquelalvarezbanos committed Oct 1, 2019
1 parent 8318f05 commit 22a6577
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/it/java/com/eprosima/integration/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;

public class Command
{
Expand All @@ -22,15 +23,23 @@ public static boolean execute(String command, String from, boolean errorOutputOn
processBuilder.redirectErrorStream(true);

Process process = processBuilder.start();
process.waitFor();

boolean status = process.exitValue() == 0;

if(!status || !errorOutputOnly)
ArrayList<String> output = new ArrayList<String>();
{
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = reader.readLine()) != null)
{
output.add(line);
}
}
process.waitFor();

boolean status = process.exitValue() == 0;

if (!status || !errorOutputOnly)
{
for (String line : output)
{
System.out.println(line);
}
Expand Down

0 comments on commit 22a6577

Please sign in to comment.