| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The base (host/scheme/port) partition key was recomputed — and a fresh key object allocated — at every site that needs it within one request: the connection-semaphore acquire, each pool poll, the completion offer, and the HTTP/2 registration. In pollPooledChannel it was computed twice on a single H2-miss (once for the HTTP/2 registry poll, once for the HTTP/1.1 pool poll). The key is immutable for a given target, so all but the first computation were pure young-gen churn. NettyResponseFuture.basePartitionKey() now memoizes the key. It depends only on targetRequest (host/scheme/port + virtualHost) and the final proxyServer, so it is invalidated in exactly one place — setTargetRequest, the sole post-construction writer of targetRequest (e.g. a redirect/retry to a different host). Behaviour is unchanged: the memoized key equals a fresh computation and is refreshed whenever the target changes, so a redirect can never reuse a connection keyed to the previous host. pollPooledChannel computes the base key once and passes it to the pollHttp2Connection(key)/poll(key) overloads instead of recomputing it inside each channelManager call. Adds a NettyResponseFuture unit test that the base key is memoized (same instance on repeat calls), equals a fresh computation, and is invalidated to the new host's key on setTargetRequest. Existing connection-pool, redirect-connection-usage and round-robin integration tests pass unchanged. No public API change. Fixes finding AsyncHttpClient#7.
…oll-key intent - NettyResponseFuture: compute the base partition key eagerly in the constructor and recompute it in setTargetRequest (via computeBasePartitionKey); basePartitionKey() is now a plain read of the volatile field, removing the reader-side write of the lazy memoize. The helper tolerates the null request/partitioning used by some unit tests. Reword the doc to name all consumers (semaphore acquire, pool offer, HTTP/2 registration) and note that the poll paths intentionally derive their key from the live request. - ChannelManager: mark the now-unused poll(Uri,...) and pollHttp2(Uri,...) overloads @deprecated pointing at the Object overloads (kept for binary compatibility). - NettyRequestSender.waitForHttp2Connection: compute the HTTP/2 poll key once before the retry loop and call pollHttp2Connection(Object); drop the private pollHttp2 helper (last caller of the deprecated overload). - Document why the round-robin base key and the pool/H2 poll keys are derived from the live request rather than future.basePartitionKey(): a filter replay can reuse a future without updating targetRequest, so the memoized key can lag a host-rewriting replay. (Declining the review suggestion to use newFuture.basePartitionKey() at the round-robin site for this reason.)
# Conflicts: # client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java
|
@pavel-ptashyts - please fix merge conflicts |
Sorry, something went wrong.
# Conflicts: # client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java
| Back | FazBrowse Home | New Git URL |
The base (host/scheme/port) partition key was recomputed — and a fresh key object allocated — at every site that needs it within one request: the connection-semaphore acquire, each pool poll, the completion offer, and the HTTP/2 registration. In pollPooledChannel it was computed twice on a single H2-miss (once for the HTTP/2 registry poll, once for the HTTP/1.1 pool poll). The key is immutable for a given target, so all but the first computation were pure young-gen churn.
NettyResponseFuture.basePartitionKey() now memoizes the key. It depends only on targetRequest (host/scheme/port + virtualHost) and the final proxyServer, so it is invalidated in exactly one place — setTargetRequest, the sole post-construction writer of targetRequest (e.g. a redirect/retry to a different host). Behaviour is unchanged: the memoized key equals a fresh computation and is refreshed whenever the target changes, so a redirect can never reuse a connection keyed to the previous host. pollPooledChannel computes the base key once and passes it to the pollHttp2Connection(key)/poll(key) overloads instead of recomputing it inside each channelManager call.
Adds a NettyResponseFuture unit test that the base key is memoized (same instance on repeat calls), equals a fresh computation, and is invalidated to the new host's key on setTargetRequest. Existing connection-pool, redirect-connection-usage and round-robin integration tests pass unchanged. No public API change.