Skip to content

Bump httpcore/httpcore-nio to 4.4.16 and fix a connection-threading regression it introduces - #119

Open
ThisaraWeerakoon wants to merge 1 commit into
apache:masterfrom
ThisaraWeerakoon:httpcore-4.4.16-bump
Open

ThisaraWeerakoon wants to merge 1 commit into
apache:masterfrom
ThisaraWeerakoon:httpcore-4.4.16-bump

Conversation

@ThisaraWeerakoon

Copy link
Copy Markdown
Contributor

What

Bumps httpcore/httpcore-nio from 4.3.3 (2014) to 4.4.16, and fixes a connection-lifecycle
regression that the bump introduces in the nhttp transport.

Why

4.3.3 is 18 releases and ~91 fixes behind. Among other things, 4.4.13+ tightened how outgoing
header values are serialized: embedded carriage-return and line-feed characters within a header
value are now normalized to a single space at write time, rather than passed through verbatim as
4.3.3 does. This brings Synapse's header output closer to what RFC 9112's field-value grammar
expects, and is one of several correctness fixes bundled into this range of releases.

The regression and its fix

In httpcore ≤4.3.x, DefaultNHttpServerConnection.produceOutput cleared the connection's
WRITE interest once its output buffer was drained. 4.4 removed that step to support request
pipelining. nhttp doesn't pipeline, and it submits a response from a worker thread rather than
the I/O dispatcher thread — with WRITE interest left permanently armed, the dispatcher thread
keeps re-entering produceOutput and can touch the connection's (non-thread-safe) session output
buffer at the same time a worker thread is writing a new response into it, corrupting its
position/limit state.

SynapseNHttpServerConnection (new) and SynapseNHttpClientConnection restore the 4.3.x
WRITE-clearing behavior, on both the server and client side of nhttp connections.

httpcore 4.4 no longer clears the WRITE interest in produceOutput once the session
output buffer is drained, so the reactor keeps re-entering it and can read a
connection's output buffer while a worker thread is writing a message head into it;
reinstate the 4.3.x condition in a shared SynapseNHttpServerConnection used by both
branches of the server connection factory and in SynapseNHttpClientConnection.

Also switch the integration echo server to ContentType.parse, since 4.4 validates
the mime type given to ContentType.create and rejects a full header value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant