Fix possible NPE in GerritJsonServlet

getMethodClass() may return null.

Change-Id: Ic596400c94515056ff64919d15f4b27e1eaf9588
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin 2015-10-27 18:01:39 +01:00 committed by David Pursehouse
parent fb83532cb3
commit 9774d2a331

View File

@ -166,14 +166,18 @@ final class GerritJsonServlet extends JsonServlet<GerritJsonServlet.GerritCall>
} }
private String extractWhat(final Audit note, final GerritCall call) { private String extractWhat(final Audit note, final GerritCall call) {
String methodClass = call.getMethodClass().getName(); Class<?> methodClass = call.getMethodClass();
methodClass = methodClass.substring(methodClass.lastIndexOf(".")+1); String methodClassName = methodClass != null
? methodClass.getName()
: "<UNKNOWN_CLASS>";
methodClassName =
methodClassName.substring(methodClassName.lastIndexOf(".") + 1);
String what = note.action(); String what = note.action();
if (what.length() == 0) { if (what.length() == 0) {
what = call.getMethod().getName(); what = call.getMethod().getName();
} }
return methodClass + "." + what; return methodClassName + "." + what;
} }
static class GerritCall extends ActiveCall { static class GerritCall extends ActiveCall {