Permalink
Browse files

avoid exchange.addExchangeCompleteListener() call if exchage is compl…

…ete in MetricsInstrumentationHandler to debug issue #299
  • Loading branch information...
ujibang committed Jul 12, 2018
1 parent c19eb3c commit 54d62a35f49d17cd07a2466df28085ebc3a1fcf7
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/main/java/org/restheart/handlers/MetricsInstrumentationHandler.java
@@ -47,11 +47,13 @@ public MetricsInstrumentationHandler(PipedHttpHandler next) {
public void handleRequest(HttpServerExchange exchange, RequestContext context) throws Exception {
final long requestStartTime = context.getRequestStartTime();
exchange.addExchangeCompleteListener((httpServerExchange, nextListener) -> {
addMetrics(requestStartTime, exchange, context);
if (!exchange.isComplete()) {
exchange.addExchangeCompleteListener((httpServerExchange, nextListener) -> {
addMetrics(requestStartTime, exchange, context);
nextListener.proceed();
});
nextListener.proceed();
});
}
if (!exchange.isResponseComplete() && getNext() != null) {
next(exchange, context);

0 comments on commit 54d62a3

Please sign in to comment.