Commit a9adb853 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '1.2.x'

parents bbaf585d 0141f50e
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -92,12 +92,17 @@ public final class CommandLineInvoker { ...@@ -92,12 +92,17 @@ public final class CommandLineInvoker {
private final Process process; private final Process process;
private final List<Thread> streamReaders = new ArrayList<Thread>();
public Invocation(Process process) { public Invocation(Process process) {
this.process = process; this.process = process;
new Thread(new StreamReadingRunnable(this.process.getErrorStream(), this.err)) this.streamReaders.add(new Thread(new StreamReadingRunnable(this.process
.start(); .getErrorStream(), this.err)));
new Thread(new StreamReadingRunnable(this.process.getInputStream(), this.out)) this.streamReaders.add(new Thread(new StreamReadingRunnable(this.process
.start(); .getInputStream(), this.out)));
for (Thread streamReader : this.streamReaders) {
streamReader.start();
}
} }
public String getErrorOutput() { public String getErrorOutput() {
...@@ -140,6 +145,9 @@ public final class CommandLineInvoker { ...@@ -140,6 +145,9 @@ public final class CommandLineInvoker {
} }
public int await() throws InterruptedException { public int await() throws InterruptedException {
for (Thread streamReader : this.streamReaders) {
streamReader.join();
}
return this.process.waitFor(); return this.process.waitFor();
} }
...@@ -171,6 +179,7 @@ public final class CommandLineInvoker { ...@@ -171,6 +179,7 @@ public final class CommandLineInvoker {
// Allow thread to die // Allow thread to die
} }
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment