-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Follow-up investigation for #12524.
Symptom
When running tests with Tomcat 10 Embedded, we encounter java.lang.IllegalStateException: The output buffer object has been recycled and is no longer associated with this facade.
This indicates that the OutputBuffer is being accessed after Tomcat has recycled it.
Root Cause Analysis (Preliminary)
It seems related to Tomcat 10's RECYCLE_FACADES optimization. The facade object (specifically the underlying OutputBuffer) appears to be recycled prematurely—likely as soon as the initial servlet request handler returns—even though gRPC is still using the AsyncContext to write the response stream asynchronously.
Current Workaround
We have disabled facade recycling (setDiscardFacades(false)) in the test environment to prevent flakiness (See PR #12530).
Goal
Investigate if gRPC's usage of AsyncContext needs adjustment to be compatible with Tomcat's facade recycling logic, or if this is an issue with Tomcat's behavior in async scenarios.