Always bind the exchange ID to the execution context

This commit is contained in:
Oleg Kalnichevski 2021-09-27 14:35:24 +02:00
parent 013851d898
commit 5390aef223
7 changed files with 14 additions and 4 deletions

View File

@ -656,6 +656,7 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
try {
final SimpleHttpResponse cacheResponse = generateCachedResponse(request, context, entry, now);
final String exchangeId = ExecSupport.getNextExchangeId();
context.setExchangeId(exchangeId);
final AsyncExecChain.Scope fork = new AsyncExecChain.Scope(
exchangeId,
scope.route,

View File

@ -278,6 +278,7 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
&& validityPolicy.mayReturnStaleWhileRevalidating(entry, now)) {
LOG.debug("Serving stale with asynchronous revalidation");
final String exchangeId = ExecSupport.getNextExchangeId();
context.setExchangeId(exchangeId);
final ExecChain.Scope fork = new ExecChain.Scope(
exchangeId,
scope.route,

View File

@ -188,12 +188,12 @@ abstract class InternalAbstractHttpAsyncClient extends AbstractHttpAsyncClientBa
httpHost != null ? httpHost : RoutingSupport.determineHost(request),
clientContext);
final String exchangeId = ExecSupport.getNextExchangeId();
clientContext.setExchangeId(exchangeId);
if (LOG.isDebugEnabled()) {
LOG.debug("{} preparing request execution", exchangeId);
}
final AsyncExecRuntime execRuntime = createAsyncExecRuntime(pushHandlerFactory);
clientContext.setExchangeId(exchangeId);
setupContext(clientContext);
final AsyncExecChain.Scheduler scheduler = this::executeScheduled;

View File

@ -213,7 +213,10 @@ public final class MinimalH2AsyncClient extends AbstractMinimalHttpAsyncClientBa
};
if (LOG.isDebugEnabled()) {
final String exchangeId = ExecSupport.getNextExchangeId();
LOG.debug("{} executing message exchange {}", exchangeId, ConnPoolSupport.getId(session));
clientContext.setExchangeId(exchangeId);
if (LOG.isDebugEnabled()) {
LOG.debug("{} executing message exchange {}", exchangeId, ConnPoolSupport.getId(session));
}
session.enqueue(
new RequestExecutionCommand(
new LoggingAsyncClientExchangeHandler(LOG, exchangeId, internalExchangeHandler),

View File

@ -136,6 +136,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
final HttpRoute route = new HttpRoute(RoutingSupport.normalize(host, schemePortResolver));
final ComplexFuture<AsyncConnectionEndpoint> resultFuture = new ComplexFuture<>(callback);
final String exchangeId = ExecSupport.getNextExchangeId();
clientContext.setExchangeId(exchangeId);
final Future<AsyncConnectionEndpoint> leaseFuture = manager.lease(
exchangeId,
route,
@ -445,16 +446,18 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
final HttpContext context) {
Asserts.check(!released.get(), "Endpoint has already been released");
final HttpClientContext clientContext = context != null ? HttpClientContext.adapt(context) : HttpClientContext.create();
final String exchangeId = ExecSupport.getNextExchangeId();
clientContext.setExchangeId(exchangeId);
if (LOG.isDebugEnabled()) {
LOG.debug("{} executing message exchange {}", exchangeId, ConnPoolSupport.getId(connectionEndpoint));
connectionEndpoint.execute(
exchangeId,
new LoggingAsyncClientExchangeHandler(LOG, exchangeId, exchangeHandler),
pushHandlerFactory,
context);
clientContext);
} else {
connectionEndpoint.execute(exchangeId, exchangeHandler, context);
connectionEndpoint.execute(exchangeId, exchangeHandler, clientContext);
}
}

View File

@ -159,6 +159,7 @@ class InternalHttpClient extends CloseableHttpClient implements Configurable {
target != null ? target : RoutingSupport.determineHost(request),
localcontext);
final String exchangeId = ExecSupport.getNextExchangeId();
localcontext.setExchangeId(exchangeId);
if (LOG.isDebugEnabled()) {
LOG.debug("{} preparing request execution", exchangeId);
}

View File

@ -132,6 +132,7 @@ public class MinimalHttpClient extends CloseableHttpClient {
final HttpRoute route = new HttpRoute(RoutingSupport.normalize(target, schemePortResolver));
final String exchangeId = ExecSupport.getNextExchangeId();
clientContext.setExchangeId(exchangeId);
final ExecRuntime execRuntime = new InternalExecRuntime(LOG, connManager, requestExecutor,
request instanceof CancellableDependency ? (CancellableDependency) request : null);
try {