Source:
public void run() { while (!shutdownReady.get()) { try { RestRequestInfo restRequestInfo = null; try { restRequestInfo = restRequestInfoQueue.take(); queuingTimeTracker.stopTracking(restRequestInfo, true); logger.debug("Dequeued RestRequestInfo - {}", restRequestInfo); restServerMetrics.dequeuedRequestHandlerDequeuingRate.mark(); if (restRequestInfo instanceof PoisonInfo) { logger.debug("Encountered PoisonInfo, shutting down"); restRequestInfo.onHandlingComplete(null); emptyQueue(); break; } handleRequest(restRequestInfo); logger.debug("RestRequestInfo was handled successfully", restRequestInfo); onHandlingComplete(restRequestInfo, null); } catch (InterruptedException e) { logger.error("Swallowing InterruptedException during dequeueing of RestRequestInfo", e); restServerMetrics.dequeuedRequestHandlerQueueTakeInterrupted.inc(); } catch (Exception e) { if (!(e instanceof RestServiceException)) { logger.error("Reporting exception encountered during handling of a dequeued RestRequestInfo", e); } restServerMetrics.dequeuedRequestHandlerRestRequestInfoHandlingFailure.inc(); onHandlingComplete(restRequestInfo, e); } } catch (Exception e) { logger.error("Swallowing unexpected exception during dequeuing and handling of RestRequestInfo", e); restServerMetrics.dequeuedRequestHandlerUnexpectedException.inc(); } } logger.debug("DequeuedRequestHandler stopped"); shutdownLatch.countDown(); }

Target:
public void run() { while (!shutdownReady.get()) { try { RestRequestInfo restRequestInfo = null; try { restRequestInfo = restRequestInfoQueue.take(); trackMetricsOnDequeue(restRequestInfo); if (restRequestInfo instanceof PoisonInfo) { logger.trace("Encountered PoisonInfo, shutting down"); restRequestInfo.onComplete(null); emptyQueue(); break; } handleRequest(restRequestInfo); logger.trace("RestRequestInfo of request was handled successfully", restRequestInfo.getRestRequestMetadata().getUri()); onHandlingComplete(restRequestInfo, null); } catch (InterruptedException e) { logger.error("Swallowing InterruptedException during dequeueing of RestRequestInfo", e); restServerMetrics.dequeuedRequestHandlerQueueTakeInterruptedError.inc(); } catch (RestServiceException e) { RestServiceErrorCode errorCode = e.getErrorCode(); if (RestServiceErrorCode.getErrorCodeGroup(errorCode) == RestServiceErrorCode.BadRequest) { logger.debug("Handling of dequeued RestRequestInfo of request failed with error code {}", restRequestInfo.getRestRequestMetadata().getUri(), errorCode, e); } else { logger.error("Handling of dequeued RestRequestInfo of request failed with error code {}", restRequestInfo.getRestRequestMetadata().getUri(), errorCode, e); } restServerMetrics.dequeuedRequestHandlerRestRequestInfoHandlingError.inc(); onHandlingComplete(restRequestInfo, e); } catch (Exception e) { logger.error("Handling of dequeued RestRequestInfo of request failed", restRequestInfo.getRestRequestMetadata().getUri(), e); restServerMetrics.dequeuedRequestHandlerRestRequestInfoHandlingError.inc(); onHandlingComplete(restRequestInfo, e); } } catch (Exception e) { logger.error("Swallowing unexpected exception during dequeuing and handling of RestRequestInfo", e); restServerMetrics.dequeuedRequestHandlerUnexpectedExceptionError.inc(); } } logger.trace("DequeuedRequestHandler stopped"); shutdownLatch.countDown(); }