RestApiServlet: Ignore exceptions when trying to consume the rest of the input When parsing the request we have a finally block to ensure that all of the request input was consumed. Trying to consume the rest of the input may fail if the request was cancelled. If the request is cancelled an exception is thrown while parsing the request, but we don't get that exception because the finally block triggers another exception. Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: Ib9ac3d7d9015a362a393af784c26b0f4fffebea4
diff --git a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java index d9bb3b9..4db9217 100644 --- a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java +++ b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
@@ -1182,8 +1182,14 @@ } return OutputFormat.JSON.newGson().fromJson(json, type); } finally { - // Reader.close won't consume the rest of the input. Explicitly consume the request body. - br.skip(Long.MAX_VALUE); + try { + // Reader.close won't consume the rest of the input. Explicitly consume the request + // body. + br.skip(Long.MAX_VALUE); + } catch (Exception e) { + // ignore, e.g. trying to consume the rest of the input may fail if the request was + // cancelled + } } } }