CmdLineAdaptor: Log stderr and fix interrupt
When the lister is interrupted, it no longer wraps the exception in an
IOException.
diff --git a/src/adaptorlib/prebuilt/CommandLineAdaptor.java b/src/adaptorlib/prebuilt/CommandLineAdaptor.java
index 73662ad..d9de5d3 100644
--- a/src/adaptorlib/prebuilt/CommandLineAdaptor.java
+++ b/src/adaptorlib/prebuilt/CommandLineAdaptor.java
@@ -43,13 +43,13 @@
try {
log.finest("Command: ./list-doc-ids.sh");
commandResult = command.exec(new String[] {"./list-doc-ids.sh"});
- } catch (InterruptedException e) {
- throw new IOException("Thread interrupted while waiting for external command.", e);
} catch (IOException e) {
throw new IOException("External command could not be executed.", e);
}
if (commandResult != 0) {
- throw new IOException("External command error. code = " + commandResult + ".");
+ String errorOutput = new String(command.getStderr(), encoding);
+ throw new IOException("External command error. code = " + commandResult + ". Stderr: "
+ + errorOutput);
}
CommandStreamParser parser = new CommandStreamParser(
@@ -81,9 +81,10 @@
throw new IOException("External command could not be executed.", e);
}
if (commandResult != 0) {
- throw new IOException("External command error. code=" + commandResult + ".");
+ String errorOutput = new String(command.getStderr(), encoding);
+ throw new IOException("External command error. code=" + commandResult + ". Stderr: "
+ + errorOutput);
}
- // TODO(johnfelton) log any output sent to stderr
CommandStreamParser parser = new CommandStreamParser(
new ByteArrayInputStream(command.getStdout()));