summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2013-05-23 13:07:03 -0700
committerShawn Pearce <spearce@spearce.org>2013-05-23 13:07:03 -0700
commit557471da2eee6752ad4305a883843bcdc8d66536 (patch)
treea08f5b2f796db6d3560ff5f64036aae8c3e33f06 /org.eclipse.jgit
parent6e896ba66ba095b97a89a622d43f05ce9ad501e7 (diff)
downloadjgit-557471da2eee6752ad4305a883843bcdc8d66536.tar.gz
jgit-557471da2eee6752ad4305a883843bcdc8d66536.zip
Use NullOutputStream not DisabledOutputStream in UploadPack
The stream should not throw IllegalStateException if it is off. Flush the stream after the hook runs, in case any messages need to be sent ahead of the pack. Change-Id: I21c7a0258ab1308406d226293fa0e7da69b4f57b
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index 6ae08acaa2..21530cca9a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -82,6 +82,7 @@ import org.eclipse.jgit.transport.BasePackFetchConnection.MultiAck;
import org.eclipse.jgit.transport.RefAdvertiser.PacketLineOutRefAdvertiser;
import org.eclipse.jgit.util.io.DisabledOutputStream;
import org.eclipse.jgit.util.io.InterruptTimer;
+import org.eclipse.jgit.util.io.NullOutputStream;
import org.eclipse.jgit.util.io.TimeoutInputStream;
import org.eclipse.jgit.util.io.TimeoutOutputStream;
@@ -193,7 +194,7 @@ public class UploadPack {
private PacketLineOut pckOut;
- private OutputStream msgOut = DisabledOutputStream.INSTANCE;
+ private OutputStream msgOut = NullOutputStream.INSTANCE;
/** The refs we advertised as existing at the start of the connection. */
private Map<String, Ref> refs;
@@ -525,7 +526,7 @@ public class UploadPack {
pckOut = new PacketLineOut(rawOut);
service();
} finally {
- msgOut = DisabledOutputStream.INSTANCE;
+ msgOut = NullOutputStream.INSTANCE;
walk.release();
if (timer != null) {
try {
@@ -1126,6 +1127,7 @@ public class UploadPack {
} else {
preUploadHook.onSendPack(this, wantAll, commonBase);
}
+ msgOut.flush();
} catch (ServiceMayNotContinueException noPack) {
if (sideband && noPack.getMessage() != null) {
noPack.setOutput();
@@ -1209,7 +1211,7 @@ public class UploadPack {
pw.writePack(pm, NullProgressMonitor.INSTANCE, packOut);
statistics = pw.getStatistics();
- if (msgOut != DisabledOutputStream.INSTANCE) {
+ if (msgOut != NullOutputStream.INSTANCE) {
String msg = pw.getStatistics().getMessage() + '\n';
msgOut.write(Constants.encode(msg));
msgOut.flush();