servlet: disable RECYCLE_FACADES to reduce flaky tests (1.76.x backport) #12633
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.
Background
In the gRPC servlet transport with Tomcat 10 Embedded,
we observed occasional flaky tests in
grpc-servlet-jakarta:tomcat10Test.The issue is related to a race condition where the OutputBuffer is prematurely recycled during asynchronous writes.
Changes
Reference: spring-projects/spring-boot#36763 (comment)
This PR explicitly calls
.setDiscardFacades(false)on the Tomcat 10 Embedded Connector.The intention is to prevent outputBuffer reuse, so that the above race condition does not occur during tests.
Purpose
grpc-servlet-jakarta:tomcat10TestNote
This change aligns Tomcat 10 Embedded behavior with Tomcat 9 (where
RECYCLE_FACADESdefaults tofalse), and is known to prevent prematureOutputBufferrecycling during async writes.Based on the investigation and prior reports (e.g., Spring Boot discussion),
this is currently the correct and safe configuration for servlet-based asynchronous responses in Tomcat 10.
Fixes #12524
Backport of #12530