From 9774d2a331036a7663f6970873d69f95254a9bb9 Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Tue, 27 Oct 2015 18:01:39 +0100 Subject: [PATCH] Fix possible NPE in GerritJsonServlet getMethodClass() may return null. Change-Id: Ic596400c94515056ff64919d15f4b27e1eaf9588 Signed-off-by: Edwin Kempin --- .../com/google/gerrit/httpd/rpc/GerritJsonServlet.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/GerritJsonServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/GerritJsonServlet.java index af20ea5ed1..3b064e282d 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/GerritJsonServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/GerritJsonServlet.java @@ -166,14 +166,18 @@ final class GerritJsonServlet extends JsonServlet } private String extractWhat(final Audit note, final GerritCall call) { - String methodClass = call.getMethodClass().getName(); - methodClass = methodClass.substring(methodClass.lastIndexOf(".")+1); + Class methodClass = call.getMethodClass(); + String methodClassName = methodClass != null + ? methodClass.getName() + : ""; + methodClassName = + methodClassName.substring(methodClassName.lastIndexOf(".") + 1); String what = note.action(); if (what.length() == 0) { what = call.getMethod().getName(); } - return methodClass + "." + what; + return methodClassName + "." + what; } static class GerritCall extends ActiveCall {