aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java
diff options
context:
space:
mode:
authorDmitry Neverov <dmitry.neverov@gmail.com>2015-12-21 20:15:42 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2015-12-24 01:20:14 +0100
commit9c71bf14b70240907ee880a18ba9977cb4e7bbdb (patch)
tree0eb429b11a3b8bbf43fc235f9d75d0a077e85e41 /org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java
parentd88695e41277fa36dd4ba5163e232cf0c39cbb51 (diff)
downloadjgit-9c71bf14b70240907ee880a18ba9977cb4e7bbdb.tar.gz
jgit-9c71bf14b70240907ee880a18ba9977cb4e7bbdb.zip
Close copy threads in case of errors
Bug: 484775 Change-Id: I3c7105188e615b6b994261f4ece0c8abc98eb444 Signed-off-by: Dmitry Neverov <dmitry.neverov@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java15
1 files changed, 14 insertions, 1 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 85109a5bf0..1dfe5d9797 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 @@ public class JschSession implements RemoteSession {
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();