388102 Jetty HttpClient memory leaks when sending larger files
This commit is contained in:
parent
3c48496a0b
commit
2ed3a1688d
|
@ -172,6 +172,9 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
protected void commitRequest() throws IOException
|
protected void commitRequest() throws IOException
|
||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
|
@ -223,6 +226,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
requestHeaders.putLongField(HttpHeaders.CONTENT_LENGTH, requestContent.length());
|
requestHeaders.putLongField(HttpHeaders.CONTENT_LENGTH, requestContent.length());
|
||||||
_generator.completeHeader(requestHeaders,false);
|
_generator.completeHeader(requestHeaders,false);
|
||||||
_generator.addContent(new View(requestContent),true);
|
_generator.addContent(new View(requestContent),true);
|
||||||
|
_exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -230,24 +234,14 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
if (requestContentStream != null)
|
if (requestContentStream != null)
|
||||||
{
|
{
|
||||||
_generator.completeHeader(requestHeaders, false);
|
_generator.completeHeader(requestHeaders, false);
|
||||||
int available = requestContentStream.available();
|
|
||||||
if (available > 0)
|
|
||||||
{
|
|
||||||
// TODO deal with any known content length
|
|
||||||
// TODO reuse this buffer!
|
|
||||||
byte[] buf = new byte[available];
|
|
||||||
int length = requestContentStream.read(buf);
|
|
||||||
_generator.addContent(new ByteArrayBuffer(buf, 0, length), false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
requestHeaders.remove(HttpHeaders.CONTENT_LENGTH);
|
requestHeaders.remove(HttpHeaders.CONTENT_LENGTH);
|
||||||
_generator.completeHeader(requestHeaders, true);
|
_generator.completeHeader(requestHeaders, true);
|
||||||
|
_exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,8 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async
|
||||||
Buffer chunk=_requestContentChunk;
|
Buffer chunk=_requestContentChunk;
|
||||||
_requestContentChunk=exchange.getRequestContentChunk(null);
|
_requestContentChunk=exchange.getRequestContentChunk(null);
|
||||||
_generator.addContent(chunk,_requestContentChunk==null);
|
_generator.addContent(chunk,_requestContentChunk==null);
|
||||||
|
if (_requestContentChunk==null)
|
||||||
|
exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,8 @@ public class BlockingHttpConnection extends AbstractHttpConnection
|
||||||
Buffer chunk=_requestContentChunk;
|
Buffer chunk=_requestContentChunk;
|
||||||
_requestContentChunk=exchange.getRequestContentChunk(null);
|
_requestContentChunk=exchange.getRequestContentChunk(null);
|
||||||
_generator.addContent(chunk,_requestContentChunk==null);
|
_generator.addContent(chunk,_requestContentChunk==null);
|
||||||
|
if (_requestContentChunk==null)
|
||||||
|
exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue