response = processor.handle(request);
}
catch (Throwable e) {
state.set("FAILED");
long responseStart = System.nanoTime();
Duration requestProcessingTime = new Duration(responseStart - requestStart, TimeUnit.NANOSECONDS);
if (e instanceof Exception) {
try {
return responseHandler.handleException(request, (Exception) e);
}
finally {
stats.record(request.getMethod(),
0,
0,
0,
requestProcessingTime,
Duration.nanosSince(responseStart));
}
}
else {
stats.record(request.getMethod(),
0,
0,
0,
requestProcessingTime,
new Duration(0, TimeUnit.NANOSECONDS));
throw (Error) e;
}
}
checkState(response != null, "response is null");
// notify handler
state.set("PROCESSING_RESPONSE");
long responseStart = System.nanoTime();
Duration requestProcessingTime = new Duration(responseStart - requestStart, TimeUnit.NANOSECONDS);
try {
return responseHandler.handle(request, response);
}
finally {
state.set("DONE");