@ Override public void handleRequest ( HttpServerExchange exchange ) throws Exception { runningCount . increment ( ) ; exchange . addExchangeCompleteListener ( new ExchangeCompletionListener ( ) { @ Override public void exchangeEvent ( HttpServerExchange exchange , NextListener nextListener ) { runningCount . decrement ( ) ; // Proceed to next listener must be called! nextListener . proceed ( ) ; } } ) ; wrappedHandler . handleRequest ( exchange ) ; }
Increments the counter and registers a listener to decrement the counter upon exchange complete event .