SOLR-9877: Null check for metric registry before attempting to use it

This commit is contained in:
Shalin Shekhar Mangar 2016-12-29 09:57:03 +05:30
parent 20362deb7e
commit 662be93ed1
1 changed files with 7 additions and 2 deletions

View File

@ -53,11 +53,16 @@ public class InstrumentedHttpRequestExecutor extends HttpRequestExecutor impleme
@Override
public HttpResponse execute(HttpRequest request, HttpClientConnection conn, HttpContext context) throws IOException, HttpException {
final Timer.Context timerContext = timer(request).time();
Timer.Context timerContext = null;
if (metricsRegistry != null) {
timerContext = timer(request).time();
}
try {
return super.execute(request, conn, context);
} finally {
timerContext.stop();
if (timerContext != null) {
timerContext.stop();
}
}
}