Skip to content

Commit

Permalink
#63: Close session after use.
Browse files Browse the repository at this point in the history
  • Loading branch information
hierynomus committed Dec 10, 2012
1 parent fcdb1dc commit e19c136
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/xebialabs/overthere/ssh/SshConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.google.common.io.Closeables;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.common.Factory;
import net.schmizz.sshj.common.SSHException;
Expand Down Expand Up @@ -234,9 +235,15 @@ public OverthereProcess startProcess(final CmdLine commandLine) {
CmdLine cmd = processCommandLine(commandLine);
try {
if (openShellBeforeExecute) {
logger.debug("Creating a temporary shell to allow for deferred home dir creation.");
Session.Shell shell = getSshClient().startSession().startShell();
shell.close();
Session session = null;
try {
logger.debug("Creating a temporary shell to allow for deferred home dir creation.");
session = getSshClient().startSession();
Session.Shell shell = session.startShell();
shell.close();
} finally {
Closeables.closeQuietly(session);
}
}

Session session = getSshClient().startSession();
Expand Down

0 comments on commit e19c136

Please sign in to comment.