Skip to content
Open
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3f87103
servlet: fix write when not ready in AsyncServletOutputStreamWriter
mgustimz May 2, 2026
60e9f16
servlet: fix write when not ready, narrow to writeBytes only
mgustimz May 5, 2026
44ee627
servlet: fix type comparison in runOrBuffer
mgustimz May 6, 2026
55e6629
Add AsyncServletOutputStreamWriterTest with mock isReady supplier
mgustimz May 6, 2026
3ebac15
Remove unused AtomicInteger in AsyncServletOutputStreamWriterTest
mgustimz May 7, 2026
1ef9eb8
Fix test and log message per Copilot review
mgustimz May 7, 2026
3f81019
Split flush and writeBytes into separate branches
mgustimz May 7, 2026
d79bdb6
Clean up test per Copilot review
mgustimz May 7, 2026
c73e67a
Add test validating write without onWritePossible is buffered
mgustimz May 7, 2026
e898755
Address Copilot review items from #4251754607
mgustimz May 8, 2026
8c217f5
Replace third test to cover flush-specific behavior
mgustimz May 8, 2026
ccb13ee
Fix flush test per Copilot review
mgustimz May 13, 2026
1a07b84
servlet: fix flush test assertion to account for buffered writeBytes
mgustimz May 25, 2026
5ec98e1
servlet: fix comment and add test for consecutive flush behavior
mgustimz May 25, 2026
7924aae
fix(servlet): address review comments in AsyncServletOutputStreamWriter
mgustimz May 26, 2026
ca8408e
fix(servlet): update log message for clarity and improve test imports
mgustimz May 26, 2026
512680b
fix(servlet): correct unpark placement and format action items in tests
mgustimz May 26, 2026
09c4a02
fix(servlet): reorder checkState calls and improve log message for wr…
mgustimz May 26, 2026
7ffb701
Merge branch 'grpc:master' into fix/12723-servlet-clean
mgustimz May 28, 2026
33b5258
servlet: avoid Tomcat write stall when still ready
mgustimz Jun 5, 2026
8b68f2b
servlet: preserve Undertow direct write flow
mgustimz Jun 5, 2026
835a5de
servlet: improve writer test coverage
mgustimz Jun 5, 2026
dfe0f33
servlet: cover writer race recovery paths
mgustimz Jun 5, 2026
e600550
servlet: fix reflective rethrow in writer test
mgustimz Jun 5, 2026
6c6a2e4
servlet: fix writer test import order
mgustimz Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,27 @@ private void runOrBuffer(ActionItem actionItem) throws IOException {
if (actionItem == completeAction) {
return;
}
if (!isReady.getAsBoolean()) {
if (actionItem == writeAction) {
Comment thread
mgustimz marked this conversation as resolved.
Outdated
// For writeBytes, always set readyAndDrained to false even when isReady()
// returns true. Tomcat requires onWritePossible() to fire between writes,
// even if isReady() is still true. For flush, keep the original behavior
// since flush is less latency-sensitive and can safely wait for
// onWritePossible.
Comment thread
mgustimz marked this conversation as resolved.
Outdated
boolean successful =
writeState.compareAndSet(curState, curState.withReadyAndDrained(false));
LockSupport.unpark(parkingThread);
checkState(successful, "Bug: curState is unexpectedly changed by another thread");
log.finest("the servlet output stream becomes not ready");
Comment thread
mgustimz marked this conversation as resolved.
} else {
// For flush, only set to false if isReady() returns false.
// If isReady() is still true, keep readyAndDrained true so flush goes direct.
if (!isReady.getAsBoolean()) {
boolean successful =
writeState.compareAndSet(curState, curState.withReadyAndDrained(false));
LockSupport.unpark(parkingThread);
checkState(successful, "Bug: curState is unexpectedly changed by another thread");
Comment thread
mgustimz marked this conversation as resolved.
Outdated
log.finest("the servlet output stream becomes not ready");
}
Comment thread
mgustimz marked this conversation as resolved.
Outdated
}
} else { // buffer to the writeChain
writeChain.offer(actionItem);
Expand Down Expand Up @@ -274,9 +289,10 @@ private static final class WriteState {
* check of {@link javax.servlet.ServletOutputStream#isReady()} is true.
*
* <p>readyAndDrained turns from true to false when:
* {@code runOrBuffer()} exits while either the action item is written directly to the
* servlet output stream and the check of {@link javax.servlet.ServletOutputStream#isReady()}
* right after that returns false, or the action item is buffered into the writeChain.
* {@code runOrBuffer()} exits after writing directly to the servlet output stream.
* For writeBytes actions, it always transitions to false. For flush actions,
* it transitions to false only when {@link javax.servlet.ServletOutputStream#isReady()}
* returns false, or when the action is buffered into the writeChain.
*/
final boolean readyAndDrained;

Expand Down
Loading