Repository navigation
servlet: Ignore stream writes after the stream is closed - #13195
Merged
kannanjgithub merged 1 commit intoNov 23, 2026
Merged
kannanjgithub merged 1 commit into
kannanjgithub merged 1 commit into
Conversation
AbstractTransportTest.frameAfterRstStreamShouldNotBreakClientChannel
checks that a client which has reset a stream ignores HEADERS/DATA
frames the server still sends on that stream (allowed by RFC 7540
section 5.1), and that the connection remains usable for new streams.
The client writes a message and cancels the stream (RST_STREAM), and
the server, without waiting, writes headers and a message on the same
stream.
With the servlet server on Jetty this was flaky: the server-side
writeHeaders() sometimes threw IllegalStateException("Committed") to the
caller. When the client's RST_STREAM races ahead of the server's write,
the container reports it via AsyncListener.onError on a container
thread, which calls Sink.cancel() -> close() and completes the
AsyncContext, committing the response. The application thread's
writeHeaders() then calls setTrailerFields() on the committed response:
16.406 client sends RST_STREAM
16.565 Jetty thread: onError -> cancel() -> close()
-> writeTrailers(headersSent=false)
16.674 Jetty thread: asyncContext.complete() <- response committed
17.396 test thread: writeHeaders -> setTrailerFields
-> IllegalStateException("Committed")
Track in the Sink whether trailers have been written and make
writeHeaders, writeFrame and writeTrailers no-ops afterwards, holding a
lock so response mutations from the application and container threads
are serialized. Writes after a cancel are thus silently dropped, as with
the Netty server.
TAG=agy
CONV=367f1e32-a85a-4e2f-99f3-3ac0e3d14e20
panchenko
approved these changes
Nov 19, 2026
shivaspeaks
approved these changes
Nov 23, 2026
kannanjgithub
deleted the
flake_frameAfterRstStreamShouldNotBreakClientChannel
branch
November 23, 2026 06:09
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 identified via flaky server transport test failures when run on Jetty.
AbstractTransportTest.frameAfterRstStreamShouldNotBreakClientChannelchecks that a client which has reset a stream ignores HEADERS/DATA frames the server still sends on that stream (allowed by RFC 7540 section 5.1), and that the connection remains usable for new streams. The client writes a message and cancels the stream (RST_STREAM), and the server, without waiting, writes headers and a message on the same stream.With the servlet server on Jetty this was flaky: the server-side writeHeaders() sometimes threw
IllegalStateException("Committed") to the caller. When the client's RST_STREAM races ahead of the server's write, the container reports it viaAsyncListener.onErroron a container thread, which callsSink.cancel() -> close()and completes theAsyncContext, committing the response. The application thread'swriteHeaders()then callssetTrailerFields()on the committed response:16.406 client sends RST_STREAM
16.565 Jetty thread:
onError -> cancel() -> close()->
writeTrailers(headersSent=false)16.674 Jetty thread:
asyncContext.complete()<-response committed17.396 test thread:
writeHeaders->setTrailerFields->
IllegalStateException("Committed")Track in the Sink whether trailers have been written and make writeHeaders, writeFrame and writeTrailers no-ops afterwards, holding a lock so response mutations from the application and container threads are serialized. Writes after a cancel are thus silently dropped.