From 6b2cfa7f3aa4ab17d30ea4e1fed925b172fd1ba1 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 16 Nov 2011 14:02:22 +0200 Subject: [PATCH] retry on user auth exception when flag set --- drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java | 2 +- .../sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java b/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java index ef86fa97ec..69a97aa1eb 100644 --- a/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java +++ b/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java @@ -378,7 +378,7 @@ public class SshjSshClient implements SshClient { @VisibleForTesting boolean shouldRetry(Exception from) { Predicate predicate = retryAuth ? Predicates. or(retryPredicate, - instanceOf(AuthorizationException.class)) : retryPredicate; + instanceOf(AuthorizationException.class), instanceOf(UserAuthException.class)) : retryPredicate; if (any(getCausalChain(from), predicate)) return true; if (!retryableMessages.equals("")) diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java index 80796f5fd8..b337301268 100644 --- a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java +++ b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java @@ -99,8 +99,10 @@ public class SshjSshClientTest { public void testOnlyRetryAuthWhenSet() { SshjSshClient ssh1 = createClient(); assert !ssh1.shouldRetry(new AuthorizationException("problem", null)); + assert !ssh1.shouldRetry(new UserAuthException("problem", null)); ssh1.retryAuth = true; assert ssh1.shouldRetry(new AuthorizationException("problem", null)); + assert ssh1.shouldRetry(new UserAuthException("problem", null)); } public void testOnlyRetryAuthWhenSetViaProperties() { @@ -108,6 +110,7 @@ public class SshjSshClientTest { props.setProperty("jclouds.ssh.retry-auth", "true"); SshjSshClient ssh1 = createClient(props); assert ssh1.shouldRetry(new AuthorizationException("problem", null)); + assert ssh1.shouldRetry(new UserAuthException("problem", null)); } public void testExceptionMessagesRetry() {