Issue #3038 SSL Connection Leak
Don't call handleContentMessage after content call if the content call returns true. This is a slight bending of the parser contract to work around the current client interpretation that a true return will prevent other events from being delivered. Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
b191d69bb0
commit
041e8fd9cf
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.client.http;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.client.HttpExchange;
|
import org.eclipse.jetty.client.HttpExchange;
|
||||||
|
@ -40,7 +39,6 @@ import org.eclipse.jetty.util.CompletableCallback;
|
||||||
|
|
||||||
public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.ResponseHandler
|
public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.ResponseHandler
|
||||||
{
|
{
|
||||||
private final AtomicReference<ContentState> handlingContent = new AtomicReference<>(ContentState.IDLE);
|
|
||||||
private final HttpParser parser;
|
private final HttpParser parser;
|
||||||
private ByteBuffer buffer;
|
private ByteBuffer buffer;
|
||||||
private boolean shutdown;
|
private boolean shutdown;
|
||||||
|
@ -265,18 +263,8 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
||||||
if (exchange == null)
|
if (exchange == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
handlingContent.set(ContentState.CONTENT);
|
|
||||||
CompletableCallback callback = new CompletableCallback()
|
CompletableCallback callback = new CompletableCallback()
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public void succeeded()
|
|
||||||
{
|
|
||||||
boolean messageComplete = !handlingContent.compareAndSet(ContentState.CONTENT, ContentState.IDLE);
|
|
||||||
super.succeeded();
|
|
||||||
if (messageComplete)
|
|
||||||
messageComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume()
|
public void resume()
|
||||||
{
|
{
|
||||||
|
@ -316,9 +304,6 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
||||||
@Override
|
@Override
|
||||||
public boolean messageComplete()
|
public boolean messageComplete()
|
||||||
{
|
{
|
||||||
if (handlingContent.compareAndSet(ContentState.CONTENT, ContentState.COMPLETE))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
HttpExchange exchange = getHttpExchange();
|
HttpExchange exchange = getHttpExchange();
|
||||||
if (exchange == null)
|
if (exchange == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -390,6 +375,4 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
||||||
{
|
{
|
||||||
return String.format("%s[%s]", super.toString(), parser);
|
return String.format("%s[%s]", super.toString(), parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ContentState { IDLE, CONTENT, COMPLETE }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1660,16 +1660,14 @@ public class HttpParser
|
||||||
_contentPosition += _contentChunk.remaining();
|
_contentPosition += _contentChunk.remaining();
|
||||||
buffer.position(buffer.position()+_contentChunk.remaining());
|
buffer.position(buffer.position()+_contentChunk.remaining());
|
||||||
|
|
||||||
boolean handle = _handler.content(_contentChunk);
|
if (_handler.content(_contentChunk))
|
||||||
|
return true;
|
||||||
|
|
||||||
if(_contentPosition == _contentLength)
|
if(_contentPosition == _contentLength)
|
||||||
{
|
{
|
||||||
setState(State.END);
|
setState(State.END);
|
||||||
boolean handleContent = handleContentMessage();
|
return handleContentMessage();
|
||||||
return handle || handleContent;
|
|
||||||
}
|
}
|
||||||
else if (handle)
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue