This is an automated email from the ASF dual-hosted git repository. snemeth pushed a commit to branch branch-3.1 in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.1 by this push: new 3a09593 HADOOP-16683. Disable retry of FailoverOnNetworkExceptionRetry in case of wrapped AccessControlException. Contributed by Adam Antal 3a09593 is described below commit 3a09593a73c1c919bebf344bd4a2afdddcbb85c9 Author: Szilard Nemeth <snem...@apache.org> AuthorDate: Tue Jan 14 11:19:52 2020 +0100 HADOOP-16683. Disable retry of FailoverOnNetworkExceptionRetry in case of wrapped AccessControlException. Contributed by Adam Antal --- .../org/apache/hadoop/io/retry/RetryPolicies.java | 12 +++++++++++- .../org/apache/hadoop/io/retry/TestRetryProxy.java | 19 +++++++++++++++++++ .../hadoop/io/retry/UnreliableImplementation.java | 7 +++++++ .../apache/hadoop/io/retry/UnreliableInterface.java | 4 ++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java index a89c3a7..fcbcc86 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java @@ -690,7 +690,8 @@ public class RetryPolicies { } else if (e instanceof InvalidToken) { return new RetryAction(RetryAction.RetryDecision.FAIL, 0, "Invalid or Cancelled Token"); - } else if (e instanceof AccessControlException) { + } else if (e instanceof AccessControlException || + hasWrappedAccessControlException(e)) { return new RetryAction(RetryAction.RetryDecision.FAIL, 0, "Access denied"); } else if (e instanceof SocketException @@ -761,4 +762,13 @@ public class RetryPolicies { return unwrapped instanceof RetriableException ? (RetriableException) unwrapped : null; } + + private static boolean hasWrappedAccessControlException(Exception e) { + Throwable throwable = e; + while (!(throwable instanceof AccessControlException) && + throwable.getCause() != null) { + throwable = throwable.getCause(); + } + return throwable instanceof AccessControlException; + } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java index 2116fb2..a1135a0 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java @@ -377,4 +377,23 @@ public class TestRetryProxy { assertEquals(RetryDecision.FAIL, caughtRetryAction.action); } } + + @Test + public void testWrappedAccessControlException() throws Exception { + RetryPolicy policy = mock(RetryPolicy.class); + RetryPolicy realPolicy = RetryPolicies.failoverOnNetworkException(5); + setupMockPolicy(policy, realPolicy); + + UnreliableInterface unreliable = (UnreliableInterface) RetryProxy.create( + UnreliableInterface.class, unreliableImpl, policy); + + try { + unreliable.failsWithWrappedAccessControlException(); + fail("Should fail"); + } catch (IOException expected) { + verify(policy, times(1)).shouldRetry(any(Exception.class), anyInt(), + anyInt(), anyBoolean()); + assertEquals(RetryDecision.FAIL, caughtRetryAction.action); + } + } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java index a20d898..15a84bb 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java @@ -139,6 +139,13 @@ class UnreliableImplementation implements UnreliableInterface { } } + public void failsWithWrappedAccessControlException() + throws IOException { + AccessControlException ace = new AccessControlException(); + IOException ioe = new IOException(ace); + throw new IOException(ioe); + } + @Override public String succeedsOnceThenFailsReturningString() throws UnreliableException, IOException, StandbyException { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java index 738a760..80bf47d 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java @@ -83,6 +83,10 @@ public interface UnreliableInterface { void failsWithAccessControlExceptionEightTimes() throws AccessControlException; + @Idempotent + void failsWithWrappedAccessControlException() + throws IOException; + public String succeedsOnceThenFailsReturningString() throws UnreliableException, StandbyException, IOException; @Idempotent --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org