diff --git a/ballerina-tests/http-interceptor-tests/tests/interceptors_special_test.bal b/ballerina-tests/http-interceptor-tests/tests/interceptors_special_test.bal index ddcbcb8c1b..a03849c532 100644 --- a/ballerina-tests/http-interceptor-tests/tests/interceptors_special_test.bal +++ b/ballerina-tests/http-interceptor-tests/tests/interceptors_special_test.bal @@ -259,10 +259,9 @@ service http:InterceptableService / on responseInterceptorWithoutCtxNextServerEP @test:Config{} function testResponseInterceptorWithoutCtxNext() returns error? { http:Response res = check responseInterceptorWithoutCtxNextClientEP->get("/"); - common:assertHeaderValue(check res.getHeader("last-interceptor"), "response-interceptor-without-ctx-next"); - common:assertHeaderValue(check res.getHeader("default-response-interceptor"), "true"); - common:assertHeaderValue(check res.getHeader("response-interceptor-without-ctx-next"), "true"); - common:assertTextPayload(check res.getTextPayload(), "Response from response interceptor"); + common:assertHeaderValue(check res.getHeader("last-interceptor"), "default-response-interceptor"); + common:assertHeaderValue(check res.getHeader("last-response-interceptor"), "true"); + test:assertEquals(res.statusCode, 202); } final http:Client requestInterceptorSkipClientEP = check new("http://localhost:" + requestInterceptorSkipTestPort.toString(), httpVersion = http:HTTP_1_1); diff --git a/changelog.md b/changelog.md index e3986ef987..bcdc283c69 100644 --- a/changelog.md +++ b/changelog.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - [Address CVE-2024-29025 netty's vulnerability](https://github.com/ballerina-platform/ballerina-library/issues/6242) +- [Fix interceptor pipeline getting exited when there is a `nil` return](https://github.com/ballerina-platform/ballerina-library/issues/6278) ## [2.10.12] - 2024-03-21 diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/HttpResponseInterceptorUnitCallback.java b/native/src/main/java/io/ballerina/stdlib/http/api/HttpResponseInterceptorUnitCallback.java index f9e8d76fff..7c601addb5 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/HttpResponseInterceptorUnitCallback.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/HttpResponseInterceptorUnitCallback.java @@ -114,8 +114,7 @@ private void validateResponseAndProceed(Object result) { return; } - if (result == null) { - requestMessage.setProperty(HttpConstants.RESPONSE_INTERCEPTOR_INDEX, -1); + if (result == null && interceptorId == -1) { sendResponseToNextService(); return; } diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternRequestContext.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternRequestContext.java index fe0daded1f..bb34ec6149 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternRequestContext.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternRequestContext.java @@ -95,6 +95,7 @@ private static Object getNextInterceptor(BObject requestCtx, BArray interceptors "no next service to be returned"); } if (interceptorIndex < 0) { + requestCtx.addNativeData(HttpConstants.RESPONSE_INTERCEPTOR_INDEX, -1); return null; } updateInterceptorIndex(requestCtx, requiredInterceptorType, interceptorIndex);