Browse Source

UploadPack: Don't buffer ls-refs output

Once we have read the user's entire command, there is no more need to
buffer our response --- even the strictest servlet engine allows
writing output once the input has been consumed.  Noticed when the
analogous code in the "fetch" command (introduced in a later patch)
overflowed its buffer:

 java.lang.OutOfMemoryError
        at java.io.ByteArrayOutputStream.hugeCapacity(ByteArrayOutputStream.java:123)
 [...]
        at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1905)
        at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1741)
        at org.eclipse.jgit.transport.UploadPack.fetchV2(UploadPack.java:1001)
        at org.eclipse.jgit.transport.UploadPack.serviceV2(UploadPack.java:1030)
        at org.eclipse.jgit.transport.UploadPack.upload(UploadPack.java:726)
        at org.eclipse.jgit.http.server.UploadPackServlet.doPost(UploadPackServlet.java:195)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

Change-Id: I33df56f1cb1c6c2c25ee95426cb7ad665134ac6b
stable-5.0
Jonathan Nieder 7 years ago
parent
commit
a99bbf162a
  1. 1
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

1
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

@ -890,6 +890,7 @@ public class UploadPack {
} else if (line != PacketLineIn.END) {
throw new PackProtocolException("unexpected " + line);
}
rawOut.stopBuffering();
adv.send(refs);
adv.end();

Loading…
Cancel
Save