Skip to content

Commit 824a788

Browse files
committed
fix logging of initdb process
1 parent adb4ff8 commit 824a788

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/java/io/zonky/test/db/postgres/embedded/EmbeddedPostgres.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,20 +573,21 @@ public EmbeddedPostgres start() throws IOException {
573573
}
574574
}
575575

576-
private static List<String> system(String... command)
576+
private void system(String... command)
577577
{
578578
try {
579579
final ProcessBuilder builder = new ProcessBuilder(command);
580-
builder.redirectError(ProcessBuilder.Redirect.PIPE);
581-
builder.redirectOutput(ProcessBuilder.Redirect.PIPE);
582580
builder.redirectErrorStream(true);
581+
builder.redirectError(errorRedirector);
582+
builder.redirectOutput(outputRedirector);
583583
final Process process = builder.start();
584+
585+
if (outputRedirector.type() == ProcessBuilder.Redirect.Type.PIPE) {
586+
ProcessOutputLogger.logOutput(LOG, process);
587+
}
584588
if (0 != process.waitFor()) {
585589
throw new IllegalStateException(String.format("Process %s failed%n%s", Arrays.asList(command), IOUtils.toString(process.getErrorStream())));
586590
}
587-
try (InputStream stream = process.getInputStream()) {
588-
return IOUtils.readLines(stream);
589-
}
590591
} catch (final RuntimeException e) { // NOPMD
591592
throw e;
592593
} catch (final Exception e) {

0 commit comments

Comments
 (0)