Skip to content

Commit 0d343ec

Browse files
authored
fix: prefer stdout (#157)
## Description Prefer stdout over stderr to cover cases when there are only warnings. If only error is present and no stdout is returned then the error will be returned instead. **Related issue (if any):** fixes #154 ## Checklist - [x] I have followed this repository's contributing guidelines. - [x] I will adhere to the project's code of conduct. Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 8a8a643 commit 0d343ec

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/main/java/com/redhat/exhort/providers/YarnBerryProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ private boolean isRoot(String name) {
8787
return name.endsWith("@workspace:.");
8888
}
8989

90+
@Override
9091
public String parseDepTreeOutput(String output) {
9192
return "[" + output.trim().replace(System.lineSeparator(), "").replace("}{", "},{") + "]";
9293
}

src/main/java/com/redhat/exhort/tools/Operations.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ public static String runProcessGetOutput(Path dir, final String[] cmdList, Strin
165165
}
166166

167167
String stdout = new String(process.getInputStream().readAllBytes());
168-
String stderr = new String(process.getErrorStream().readAllBytes());
169168

170-
// TODO: This should throw an exception if the process fails
171-
if (!stderr.isBlank()) {
172-
return stderr.trim();
169+
if (!stdout.isBlank()) {
170+
return stdout.trim();
173171
}
174-
return stdout.trim();
172+
// TODO: This should throw an exception if the process fails
173+
String stderr = new String(process.getErrorStream().readAllBytes());
174+
return stderr.trim();
175175
} catch (IOException e) {
176176
throw new RuntimeException(
177177
String.format("Failed to execute command '%s' ", join(" ", cmdList)), e);

0 commit comments

Comments
 (0)