Skip to content

Commit

Permalink
Merge pull request #1927 from ballerina-platform/fix-interceptor-return
Browse files Browse the repository at this point in the history
Fix `nil` return in interceptor which exit the interceptor pipeline
  • Loading branch information
TharmiganK authored Apr 8, 2024
2 parents 4ee81da + 1214e19 commit 9e618bb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9e618bb

Please sign in to comment.