diff --git a/handler/src/main/java/com/networknt/handler/RequestInterceptorInjectionHandler.java b/handler/src/main/java/com/networknt/handler/RequestInterceptorInjectionHandler.java index e3bc1095e4..5bfbc618fd 100644 --- a/handler/src/main/java/com/networknt/handler/RequestInterceptorInjectionHandler.java +++ b/handler/src/main/java/com/networknt/handler/RequestInterceptorInjectionHandler.java @@ -137,7 +137,11 @@ public void handleRequest(HttpServerExchange httpServerExchange) throws Exceptio // no need to inject the content for the body. just call the interceptors here. this.invokeInterceptors(httpServerExchange); } - Handler.next(httpServerExchange, next); + // If there are any error and one of the interceptor response the error to the caller, we don't need to call the next. + if(logger.isTraceEnabled()) logger.trace("Exchange response started status = {}", httpServerExchange.isResponseStarted()); + if(!httpServerExchange.isResponseStarted()) { + Handler.next(httpServerExchange, next); + } } /**