Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2012-08-30 05:37:32 +0000
committerJan Bartel2012-08-30 05:37:32 +0000
commit2ed3a1688dc9720ffa46252db87472bed8cc43a9 (patch)
tree5c7189e7061600f9946d06bf0fdb0e5aa5073974
parent3c48496a0b10d12210d4bde4e4129bd1147a59d6 (diff)
downloadorg.eclipse.jetty.project-2ed3a1688dc9720ffa46252db87472bed8cc43a9.tar.gz
org.eclipse.jetty.project-2ed3a1688dc9720ffa46252db87472bed8cc43a9.tar.xz
org.eclipse.jetty.project-2ed3a1688dc9720ffa46252db87472bed8cc43a9.zip
388102 Jetty HttpClient memory leaks when sending larger files
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java16
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java2
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java2
3 files changed, 9 insertions, 11 deletions
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java
index 0ff501e864..3cb1a90656 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java
@@ -172,6 +172,9 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
{
}
+ /**
+ * @throws IOException
+ */
protected void commitRequest() throws IOException
{
synchronized (this)
@@ -223,6 +226,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
requestHeaders.putLongField(HttpHeaders.CONTENT_LENGTH, requestContent.length());
_generator.completeHeader(requestHeaders,false);
_generator.addContent(new View(requestContent),true);
+ _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
}
else
{
@@ -230,24 +234,14 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
if (requestContentStream != null)
{
_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
{
requestHeaders.remove(HttpHeaders.CONTENT_LENGTH);
_generator.completeHeader(requestHeaders, true);
+ _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
}
}
-
- _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
}
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java
index 1ea6b06721..dbb75d897c 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java
@@ -114,6 +114,8 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async
Buffer chunk=_requestContentChunk;
_requestContentChunk=exchange.getRequestContentChunk(null);
_generator.addContent(chunk,_requestContentChunk==null);
+ if (_requestContentChunk==null)
+ exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
}
}
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java
index c10319fdeb..454cee300e 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java
@@ -122,6 +122,8 @@ public class BlockingHttpConnection extends AbstractHttpConnection
Buffer chunk=_requestContentChunk;
_requestContentChunk=exchange.getRequestContentChunk(null);
_generator.addContent(chunk,_requestContentChunk==null);
+ if (_requestContentChunk==null)
+ exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
}
}
}

Back to the top