|
17 | 17 | import java.util.Collections; |
18 | 18 | import java.util.List; |
19 | 19 | import java.util.Scanner; |
| 20 | +import java.util.stream.Collectors; |
| 21 | +import java.util.stream.Stream; |
20 | 22 |
|
21 | 23 | import org.apache.logging.log4j.LogManager; |
22 | 24 | import org.apache.logging.log4j.Logger; |
@@ -47,15 +49,17 @@ public CommandResult runCommand(String command) { |
47 | 49 | InputStream errorInputStream = process.getErrorStream()) { |
48 | 50 | List<String> outputMessage = inputStreamArrayToList(inputStream); |
49 | 51 | List<String> errorMessage = inputStreamArrayToList(errorInputStream); |
| 52 | + List<String> combinedMessages = Stream.concat(outputMessage.stream(), errorMessage.stream()) |
| 53 | + .collect(Collectors.toList()); |
50 | 54 | int errCode = process.waitFor(); |
51 | 55 | if (Integer.valueOf(errCode).equals(0)) { |
52 | 56 | commandResult = new CommandResult(command, true, outputMessage); |
53 | 57 | logger.info("Execution of Command {} was successful!: {}", |
54 | | - commandResult.getCommand(), commandResult.getMessages()); |
| 58 | + commandResult.getCommand(), combinedMessages); |
55 | 59 | } else { |
56 | 60 | commandResult = new CommandResult(command, false, errorMessage); |
57 | 61 | logger.error("Execution of Command {} failed!: {}", |
58 | | - commandResult.getCommand(), commandResult.getMessages()); |
| 62 | + commandResult.getCommand(), combinedMessages); |
59 | 63 | } |
60 | 64 | } |
61 | 65 | } catch (InterruptedException e) { |
|
0 commit comments