Merge pull request #2953 from eclipse/jetty-9.4.x-859-httpclient_stack_overflow

Fixes #859 - Stack overflow error in jetty high level API.
This commit is contained in:
Simone Bordet 2018-10-05 08:10:35 +02:00 committed by GitHub
commit a056695687
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 4 deletions

View File

@ -19,6 +19,8 @@
package org.eclipse.jetty.client;
import java.nio.ByteBuffer;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
@ -338,18 +340,31 @@ public abstract class HttpSender implements AsyncContentProvider.Listener
}
}
protected boolean anyToFailure(Throwable failure)
private void anyToFailure(Throwable failure)
{
HttpExchange exchange = getHttpExchange();
if (exchange == null)
return false;
return;
// Mark atomically the request as completed, with respect
// to concurrency between request success and request failure.
if (exchange.requestComplete(failure))
return abort(exchange, failure);
executeAbort(exchange, failure);
}
return false;
private void executeAbort(HttpExchange exchange, Throwable failure)
{
try
{
Executor executor = getHttpChannel().getHttpDestination().getHttpClient().getExecutor();
executor.execute(() -> abort(exchange, failure));
}
catch (RejectedExecutionException x)
{
if (LOG.isDebugEnabled())
LOG.debug(x);
abort(exchange, failure);
}
}
private void terminateRequest(HttpExchange exchange)