Skip to content

Commit

Permalink
Merge pull request #2953 from eclipse/jetty-9.4.x-859-httpclient_stac…
Browse files Browse the repository at this point in the history
…k_overflow

Fixes #859 - Stack overflow error in jetty high level API.
  • Loading branch information
sbordet committed Oct 5, 2018
2 parents 64dc930 + 20db670 commit a056695
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -338,18 +340,31 @@ protected boolean someToSuccess(HttpExchange exchange)
}
}

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)
Expand Down

0 comments on commit a056695

Please sign in to comment.