From b158469d2d48a356c4b07fe3e58b54da9f8303b1 Mon Sep 17 00:00:00 2001 From: Eryk Szymanski Date: Mon, 18 Jul 2016 12:25:15 +0200 Subject: [PATCH] Catch NumberFormatException on invalid request This prevents NumberFormatException in RestApiServlet on queries like: GET /gerrit/changes/?n=25&O=815%20oR%209%3D9%20%2B%201 Which results with ERROR| RestApiServlet | Error in GET /gerrit/changes/?n=25&O=815%20oR%209%3D9%20%2B%201 java.lang.NumberFormatException: For input string: "815 oR 9=9 + 1" plus the stack trace without this patch. Change-Id: I631c51e768095998f87d861fd09d0394f23c81c1 Signed-off-by: Eryk Szymanski --- .../java/com/google/gerrit/httpd/restapi/ParameterParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/ParameterParser.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/ParameterParser.java index 4dd21aec61..f80cc498e9 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/ParameterParser.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/ParameterParser.java @@ -66,7 +66,7 @@ class ParameterParser { CmdLineParser clp = parserFactory.create(param); try { clp.parseOptionMap(in); - } catch (CmdLineException e) { + } catch (CmdLineException | NumberFormatException e) { if (!clp.wasHelpRequestedByOption()) { replyError(req, res, SC_BAD_REQUEST, e.getMessage(), e); return false;