Background processes won't set the return code, so don't allow it to be queried.

This commit is contained in:
jeb228 2010-08-18 16:33:33 +00:00
parent 688f2f47f1
commit 60444bb7f8

View file

@ -28,7 +28,7 @@ import java.util.Map;
*/ */
public class CommandRunner { public class CommandRunner {
private int returnCode; private Integer returnCode;
private String stdOut = ""; private String stdOut = "";
private String stdErr = ""; private String stdErr = "";
private File workingDirectory; private File workingDirectory;
@ -121,10 +121,8 @@ public class CommandRunner {
} }
Process process = builder.start(); Process process = builder.start();
StreamEater outputEater = new StreamEater(process.getInputStream(), new StreamEater(process.getInputStream(), false);
false); new StreamEater(process.getErrorStream(), true);
StreamEater errorEater = new StreamEater(process.getErrorStream(),
true);
} catch (IOException e) { } catch (IOException e) {
throw new CommandRunnerException( throw new CommandRunnerException(
@ -133,6 +131,9 @@ public class CommandRunner {
} }
public int getReturnCode() { public int getReturnCode() {
if (returnCode == null) {
throw new IllegalStateException("Return code is not available.");
}
return returnCode; return returnCode;
} }