diff options
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java | 7 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java | 19 |
2 files changed, 24 insertions, 2 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java index 92d41a0caf..6d0d64fc63 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java @@ -107,7 +107,12 @@ class UploadPackServlet extends HttpServlet { up.setBiDirectionalPipe(false); rsp.setContentType(RSP_TYPE); - final SmartOutputStream out = new SmartOutputStream(req, rsp); + final SmartOutputStream out = new SmartOutputStream(req, rsp) { + @Override + public void flush() throws IOException { + doFlush(); + } + }; up.upload(getInputStream(req), out, null); out.close(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java index 6c421c5f50..101b6056bc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java @@ -139,6 +139,19 @@ public abstract class TemporaryBuffer extends OutputStream { } /** + * Dumps the entire buffer into the overflow stream, and flushes it. + * + * @throws IOException + * the overflow stream cannot be started, or the buffer contents + * cannot be written to it, or it failed to flush. + */ + protected void doFlush() throws IOException { + if (overflow == null) + switchToOverflow(); + overflow.flush(); + } + + /** * Copy all bytes remaining on the input stream into this buffer. * * @param in @@ -260,6 +273,11 @@ public abstract class TemporaryBuffer extends OutputStream { if (blocks.size() * Block.SZ < inCoreLimit) return false; + switchToOverflow(); + return true; + } + + private void switchToOverflow() throws IOException { overflow = overflow(); final Block last = blocks.remove(blocks.size() - 1); @@ -269,7 +287,6 @@ public abstract class TemporaryBuffer extends OutputStream { overflow = new BufferedOutputStream(overflow, Block.SZ); overflow.write(last.buffer, 0, last.count); - return true; } public void close() throws IOException { |