retry on user auth exception when flag set

This commit is contained in:
Adrian Cole 2011-11-16 14:02:22 +02:00
parent 6392edfcee
commit 6b2cfa7f3a
2 changed files with 4 additions and 1 deletions

View File

@ -378,7 +378,7 @@ public class SshjSshClient implements SshClient {
@VisibleForTesting @VisibleForTesting
boolean shouldRetry(Exception from) { boolean shouldRetry(Exception from) {
Predicate<Throwable> predicate = retryAuth ? Predicates.<Throwable> or(retryPredicate, Predicate<Throwable> predicate = retryAuth ? Predicates.<Throwable> or(retryPredicate,
instanceOf(AuthorizationException.class)) : retryPredicate; instanceOf(AuthorizationException.class), instanceOf(UserAuthException.class)) : retryPredicate;
if (any(getCausalChain(from), predicate)) if (any(getCausalChain(from), predicate))
return true; return true;
if (!retryableMessages.equals("")) if (!retryableMessages.equals(""))

View File

@ -99,8 +99,10 @@ public class SshjSshClientTest {
public void testOnlyRetryAuthWhenSet() { public void testOnlyRetryAuthWhenSet() {
SshjSshClient ssh1 = createClient(); SshjSshClient ssh1 = createClient();
assert !ssh1.shouldRetry(new AuthorizationException("problem", null)); assert !ssh1.shouldRetry(new AuthorizationException("problem", null));
assert !ssh1.shouldRetry(new UserAuthException("problem", null));
ssh1.retryAuth = true; ssh1.retryAuth = true;
assert ssh1.shouldRetry(new AuthorizationException("problem", null)); assert ssh1.shouldRetry(new AuthorizationException("problem", null));
assert ssh1.shouldRetry(new UserAuthException("problem", null));
} }
public void testOnlyRetryAuthWhenSetViaProperties() { public void testOnlyRetryAuthWhenSetViaProperties() {
@ -108,6 +110,7 @@ public class SshjSshClientTest {
props.setProperty("jclouds.ssh.retry-auth", "true"); props.setProperty("jclouds.ssh.retry-auth", "true");
SshjSshClient ssh1 = createClient(props); SshjSshClient ssh1 = createClient(props);
assert ssh1.shouldRetry(new AuthorizationException("problem", null)); assert ssh1.shouldRetry(new AuthorizationException("problem", null));
assert ssh1.shouldRetry(new UserAuthException("problem", null));
} }
public void testExceptionMessagesRetry() { public void testExceptionMessagesRetry() {