GitwebServlet: Write only one log entry for CGI errors
If a separate log statement is written for each line then the entries in
the log file can be interleaved with log entries from other threads,
which makes them less readable.
Change-Id: I038a0d8bc906746cc23b8f3bfb31d6c4d98b53c0
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebServlet.java
index 8fcb8c6..c5907c9 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebServlet.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/gitweb/GitwebServlet.java
@@ -645,12 +645,17 @@
private void copyStderrToLog(final InputStream in) {
new Thread(
() -> {
+ StringBuilder b = new StringBuilder();
try (BufferedReader br =
new BufferedReader(new InputStreamReader(in, ISO_8859_1.name()))) {
String line;
while ((line = br.readLine()) != null) {
- log.error("CGI: " + line);
+ if (b.length() > 0) {
+ b.append('\n');
+ }
+ b.append("CGI: ").append(line);
}
+ log.error(b.toString());
} catch (IOException e) {
log.error("Unexpected error copying stderr from CGI", e);
}