Close copy threads in case of errors

Bug: 484775
Change-Id: I3c7105188e615b6b994261f4ece0c8abc98eb444
Signed-off-by: Dmitry Neverov <dmitry.neverov@gmail.com>
This commit is contained in:
Dmitry Neverov 2015-12-21 20:15:42 +01:00 committed by Matthias Sohn
parent d88695e412
commit 9c71bf14b7
1 changed files with 14 additions and 1 deletions

View File

@ -149,14 +149,27 @@ private class JschProcess extends Process {
channel.setCommand(commandName); channel.setCommand(commandName);
setupStreams(); setupStreams();
channel.connect(timeout > 0 ? timeout * 1000 : 0); channel.connect(timeout > 0 ? timeout * 1000 : 0);
if (!channel.isConnected()) if (!channel.isConnected()) {
closeOutputStream();
throw new TransportException(uri, throw new TransportException(uri,
JGitText.get().connectionFailed); JGitText.get().connectionFailed);
}
} catch (JSchException e) { } catch (JSchException e) {
closeOutputStream();
throw new TransportException(uri, e.getMessage(), e); 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 { private void setupStreams() throws IOException {
inputStream = channel.getInputStream(); inputStream = channel.getInputStream();