RestApiServlet: log exceptions if REST-API status >= 400
Do not swallow the exceptions that caused REST-API to return
with a status >= 400.
Include the associated exception as the cause with the
relevant stack-trace so that a Gerrit administrator, by enabling
the log for the RestApiServlet class can troubleshoot the
problem and make the necessary fixes to the configuration or
potentially identify a bug in Gerrit.
Bug: Issue 11110
Change-Id: I1865df0beb3206d637c0308569857f1316e1a292
diff --git a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
index 588f349..ffd5b59 100644
--- a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
+++ b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
@@ -1442,7 +1442,7 @@
configureCaching(req, res, null, null, c);
checkArgument(statusCode >= 400, "non-error status: %s", statusCode);
res.setStatus(statusCode);
- logger.atFinest().log("REST call failed: %d", statusCode);
+ logger.atFinest().withCause(err).log("REST call failed: %d", statusCode);
return replyText(req, res, true, msg);
}