diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java index a2c572c60..7b6d3e121 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java @@ -282,8 +282,10 @@ abstract class BasePackConnection extends BaseConnection { public void close() { if (out != null) { try { - if (outNeedsEnd) + if (outNeedsEnd) { + outNeedsEnd = false; pckOut.end(); + } out.close(); } catch (IOException err) { // Ignore any close errors. @@ -314,4 +316,23 @@ abstract class BasePackConnection extends BaseConnection { } } } + + /** Tell the peer we are disconnecting, if it cares to know. */ + protected void endOut() { + if (outNeedsEnd && out != null) { + try { + outNeedsEnd = false; + pckOut.end(); + } catch (IOException e) { + try { + out.close(); + } catch (IOException err) { + // Ignore any close errors. + } finally { + out = null; + pckOut = null; + } + } + } + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java index d4d4f5412..fb2038b86 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java @@ -264,6 +264,8 @@ public class TransportGitSsh extends SshTransport implements PackTransport { @Override public void close() { + endOut(); + if (errorThread != null) { try { errorThread.join(); @@ -331,6 +333,8 @@ public class TransportGitSsh extends SshTransport implements PackTransport { @Override public void close() { + endOut(); + if (errorThread != null) { try { errorThread.join();