If we don't close the transport when we are done with it the SSH session stored within the Transport will still be opened to the remote side. JSch may have created one or more background user threads to handle that connection, which means the JVM won't terminate cleanly when we are done with our work. We must close each and every transport we opened. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../src/org/spearce/jgit/pgm/Push.java | 24 ++++++++++++------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Push.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Push.java index f53f2fe..53ad080 100644 --- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Push.java +++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Push.java @@ -50,6 +50,7 @@ import org.spearce.jgit.transport.RefSpec; import org.spearce.jgit.transport.RemoteRefUpdate; import org.spearce.jgit.transport.Transport; +import org.spearce.jgit.transport.URIish; import org.spearce.jgit.transport.RemoteRefUpdate.Status; @Command(common = true, usage = "Update remote repository from local refs") @@ -111,13 +112,18 @@ protected void run() throws Exception { final Collection<RemoteRefUpdate> toPush = transport .findRemoteRefUpdatesFor(refSpecs); - final PushResult result = transport.push(new TextProgressMonitor(), - toPush); - printPushResult(transport, result); + final URIish uri = transport.getURI(); + final PushResult result; + try { + result = transport.push(new TextProgressMonitor(), toPush); + } finally { + transport.close(); + } + printPushResult(uri, result); } } - private void printPushResult(final Transport transport, + private void printPushResult(final URIish uri, final PushResult result) { shownURI = false; boolean everythingUpToDate = true; @@ -126,7 +132,7 @@ private void printPushResult(final Transport transport, for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { if (rru.getStatus() == Status.UP_TO_DATE) { if (verbose) - printRefUpdateResult(transport, result, rru); + printRefUpdateResult(uri, result, rru); } else everythingUpToDate = false; } @@ -134,25 +140,25 @@ private void printPushResult(final Transport transport, for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { // ...then successful updates... if (rru.getStatus() == Status.OK) - printRefUpdateResult(transport, result, rru); + printRefUpdateResult(uri, result, rru); } for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { // ...finally, others (problematic) if (rru.getStatus() != Status.OK && rru.getStatus() != Status.UP_TO_DATE) - printRefUpdateResult(transport, result, rru); + printRefUpdateResult(uri, result, rru); } if (everythingUpToDate) out.println("Everything up-to-date"); } - private void printRefUpdateResult(final Transport transport, + private void printRefUpdateResult(final URIish uri, final PushResult result, final RemoteRefUpdate rru) { if (!shownURI) { shownURI = true; - out.format("To %s\n", transport.getURI()); + out.format("To %s\n", uri); } final String remoteName = rru.getRemoteName(); -- 1.6.0.174.gd789c -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html