more retryable sshj exceptions

This commit is contained in:
Adrian Cole 2011-10-14 19:04:59 -07:00
parent 52d978a602
commit 4dae25ce2c
2 changed files with 5 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import static org.jclouds.crypto.SshKeys.sha1PrivateKey;
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
@ -118,7 +119,8 @@ public class SshjSshClient implements SshClient {
@Named("jclouds.ssh.retry-predicate")
// NOTE cannot retry io exceptions, as SSHException is a part of the chain
private Predicate<Throwable> retryPredicate = or(instanceOf(ConnectionException.class),
instanceOf(ConnectException.class), instanceOf(TransportException.class));
instanceOf(ConnectException.class), instanceOf(SocketTimeoutException.class),
instanceOf(TransportException.class));
@Resource
@Named("jclouds.ssh")

View File

@ -22,6 +22,7 @@ import static com.google.inject.name.Names.bindProperties;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.util.Properties;
import net.schmizz.sshj.common.SSHException;
@ -86,6 +87,7 @@ public class SshjSshClientTest {
}
public void testExceptionClassesRetry() {
assert ssh.shouldRetry(new SocketTimeoutException("connect timed out"));
assert ssh.shouldRetry(new TransportException("socket closed"));
assert ssh.shouldRetry(new ConnectionException("problem"));
assert ssh.shouldRetry(new ConnectException("Connection refused"));