/** In rare cases, we might write something to stderr. Append it to the real test.log. */ protected static void appendStderr(Path stdOut, Path stdErr) throws IOException { FileStatus stat = stdErr.statNullable(); OutputStream out = null; InputStream in = null; if (stat != null) { try { if (stat.getSize() > 0) { if (stdOut.exists()) { stdOut.setWritable(true); } out = stdOut.getOutputStream(true); in = stdErr.getInputStream(); ByteStreams.copy(in, out); } } finally { Closeables.close(out, true); Closeables.close(in, true); stdErr.delete(); } } }