From a0a8a6a3e48d4f872e92dfed4ee6b40a5a177a42 Mon Sep 17 00:00:00 2001 From: Dmitry Neverov Date: Mon, 13 Mar 2017 12:05:44 +0100 Subject: [PATCH] Terminate StreamCopy threads in case of errors Bug: 513554 Change-Id: I065836b8fc77ade6de92e4a809fcf770a4f793ec Signed-off-by: Dmitry Neverov --- .../src/org/eclipse/jgit/transport/JschSession.java | 1 + .../org/eclipse/jgit/transport/TransportGitSsh.java | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java index 82d6ed4e48..a8cc032006 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java @@ -220,6 +220,7 @@ public class JschSession implements RemoteSession { public void destroy() { if (channel.isConnected()) channel.disconnect(); + closeOutputStream(); } @Override 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 9a40f47cb7..ede5a7ae33 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java @@ -283,12 +283,12 @@ public class TransportGitSsh extends SshTransport implements PackTransport { init(process.getInputStream(), process.getOutputStream()); } catch (TransportException err) { - close(); throw err; - } catch (IOException err) { - close(); + } catch (Throwable err) { throw new TransportException(uri, JGitText.get().remoteHungUpUnexpectedly, err); + } finally { + close(); } try { @@ -341,12 +341,12 @@ public class TransportGitSsh extends SshTransport implements PackTransport { init(process.getInputStream(), process.getOutputStream()); } catch (TransportException err) { - close(); throw err; - } catch (IOException err) { - close(); + } catch (Throwable err) { throw new TransportException(uri, JGitText.get().remoteHungUpUnexpectedly, err); + } finally { + close(); } try { -- 2.39.5