461499 - ConnectionPool may leak connections.
Avoid that the complete event is notified before or concurrently with the response success event.
This commit is contained in:
parent
7bc2d50bf7
commit
07d29fb1b3
|
@ -33,6 +33,7 @@ import org.eclipse.jetty.client.api.Response;
|
||||||
import org.eclipse.jetty.client.api.Result;
|
import org.eclipse.jetty.client.api.Result;
|
||||||
import org.eclipse.jetty.http.HttpField;
|
import org.eclipse.jetty.http.HttpField;
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.util.BufferUtil;
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
import org.eclipse.jetty.util.Callback;
|
import org.eclipse.jetty.util.Callback;
|
||||||
import org.eclipse.jetty.util.CountingCallback;
|
import org.eclipse.jetty.util.CountingCallback;
|
||||||
|
@ -366,8 +367,7 @@ public abstract class HttpReceiver
|
||||||
{
|
{
|
||||||
// Mark atomically the response as completed, with respect
|
// Mark atomically the response as completed, with respect
|
||||||
// to concurrency between response success and response failure.
|
// to concurrency between response success and response failure.
|
||||||
boolean completed = exchange.responseComplete(null);
|
if (!exchange.responseComplete(null))
|
||||||
if (!completed)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
responseState.set(ResponseState.IDLE);
|
responseState.set(ResponseState.IDLE);
|
||||||
|
@ -375,13 +375,6 @@ public abstract class HttpReceiver
|
||||||
// Reset to be ready for another response.
|
// Reset to be ready for another response.
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
// Mark atomically the response as terminated, with
|
|
||||||
// respect to concurrency between request and response.
|
|
||||||
Result result = exchange.terminateResponse();
|
|
||||||
|
|
||||||
// Notify *after* resetting and terminating, because
|
|
||||||
// the notification may trigger another request/response,
|
|
||||||
// or the reset of the response in case of 100-Continue.
|
|
||||||
HttpResponse response = exchange.getResponse();
|
HttpResponse response = exchange.getResponse();
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Response success {}", response);
|
LOG.debug("Response success {}", response);
|
||||||
|
@ -389,6 +382,14 @@ public abstract class HttpReceiver
|
||||||
ResponseNotifier notifier = getHttpDestination().getResponseNotifier();
|
ResponseNotifier notifier = getHttpDestination().getResponseNotifier();
|
||||||
notifier.notifySuccess(listeners, response);
|
notifier.notifySuccess(listeners, response);
|
||||||
|
|
||||||
|
// Special case for 100 Continue that cannot
|
||||||
|
// be handled by the ContinueProtocolHandler.
|
||||||
|
if (exchange.getResponse().getStatus() == HttpStatus.CONTINUE_100)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Mark atomically the response as terminated, with
|
||||||
|
// respect to concurrency between request and response.
|
||||||
|
Result result = exchange.terminateResponse();
|
||||||
terminateResponse(exchange, result);
|
terminateResponse(exchange, result);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -303,8 +303,7 @@ public abstract class HttpSender implements AsyncContentProvider.Listener
|
||||||
{
|
{
|
||||||
// Mark atomically the request as completed, with respect
|
// Mark atomically the request as completed, with respect
|
||||||
// to concurrency between request success and request failure.
|
// to concurrency between request success and request failure.
|
||||||
boolean completed = exchange.requestComplete(null);
|
if (!exchange.requestComplete(null))
|
||||||
if (!completed)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
requestState.set(RequestState.QUEUED);
|
requestState.set(RequestState.QUEUED);
|
||||||
|
|
Loading…
Reference in New Issue