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 85109a5bf..1dfe5d979 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java @@ -149,14 +149,27 @@ private class JschProcess extends Process { channel.setCommand(commandName); setupStreams(); channel.connect(timeout > 0 ? timeout * 1000 : 0); - if (!channel.isConnected()) + if (!channel.isConnected()) { + closeOutputStream(); throw new TransportException(uri, JGitText.get().connectionFailed); + } } catch (JSchException e) { + closeOutputStream(); throw new TransportException(uri, e.getMessage(), e); } } + private void closeOutputStream() { + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException ioe) { + // ignore + } + } + } + private void setupStreams() throws IOException { inputStream = channel.getInputStream();