Extra sage-guards for concurrent connection endpoint acquisition and request execution cancellation

This commit is contained in:
Oleg Kalnichevski 2021-04-28 16:31:16 +02:00
parent 09f50cd80c
commit d8d7ad37a3
1 changed files with 5 additions and 1 deletions

View File

@ -103,11 +103,11 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
final LeaseRequest connRequest = manager.lease(id, route, connectionRequestTimeout, object);
state = object;
if (cancellableDependency != null) {
cancellableDependency.setDependency(connRequest);
if (cancellableDependency.isCancelled()) {
connRequest.cancel();
throw new RequestFailedException("Request aborted");
}
cancellableDependency.setDependency(connRequest);
}
try {
final ConnectionEndpoint connectionEndpoint = connRequest.get(connectionRequestTimeout);
@ -115,6 +115,10 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
reusable = connectionEndpoint.isConnected();
if (cancellableDependency != null) {
cancellableDependency.setDependency(this);
if (cancellableDependency.isCancelled()) {
cancel();
throw new RequestFailedException("Request aborted");
}
}
if (log.isDebugEnabled()) {
log.debug("{} acquired endpoint {}", id, ConnPoolSupport.getId(connectionEndpoint));