From 6c2a1302c5fd098fb12ba256e561adf99b7c1835 Mon Sep 17 00:00:00 2001 From: Steve Hu Date: Wed, 1 Mar 2023 11:12:55 -0500 Subject: [PATCH] =?UTF-8?q?fixes=20#1634=20do=20not=20call=20the=20next=20?= =?UTF-8?q?handler=20in=20the=20chain=20if=20any=20intercep=E2=80=A6=20(#1?= =?UTF-8?q?635)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixes #1634 do not call the next handler in the chain if any interceptor respond * fixes #1634 add a logging --- .../handler/RequestInterceptorInjectionHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); + } } /**