Remove startAsync() to prevent void methods from hanging forever#1600
Open
Remove startAsync() to prevent void methods from hanging forever#1600
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #1598
Description of changes:
Root Cause
The
springboot4module unconditionally callshttpServletRequest.startAsync()before delegating toAwsSpringHttpProcessingUtils.processRequest(). This call present in bothSpringDelegatingLambdaContainerHandler.handleRequest()andAwsSpringWebCustomRuntimeEventLoop.eventLoop(), it sets the request's dispatcher type toDispatcherType.ASYNC.After
ServerlessMVC.service()processes the request and the servlet/filter chain completes, there is a safety-net flush that ensures the response is always committed:Because
startAsync()forces the dispatcher type toASYNC, this safety net is skipped. For controllers that return a response body, this doesn't matter - Spring'sHttpMessageConverterflushes the output stream during body serialization, which triggersAwsHttpServletResponse.flushBuffer()->writersCountDownLatch.countDown(). But for void-returning controllers (e.g. a POST that creates a resource and returns nothing), no message converter runs, no flush ever happens,countDown()is never called, andlatch.await(15, TimeUnit.MINUTES)blocks indefinitely.The
springboot3module does NOT callstartAsync(), so the safety-net flush always executes and the latch always counts down - even for void-returning controllers. This is why the same controller code works with Spring Boot 3 but hangs with Spring Boot 4.Fix
Remove the unconditional
httpServletRequest.startAsync()calls from bothSpringDelegatingLambdaContainerHandlerandAwsSpringWebCustomRuntimeEventLoop, aligning the springboot4 behavior with springboot3.Changes
SpringDelegatingLambdaContainerHandler.java: RemovedhttpServletRequest.startAsync()callAwsSpringWebCustomRuntimeEventLoop.java: RemovedhttpServletRequest.startAsync()callSpringDelegatingLambdaContainerHandlerTests.java: AddedvoidPost_returns200test that verifies void-returning POST controllers complete successfullyServletApplication.java: AddedvoidPost()endpoint for the new testBy submitting this pull request