This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 3a90de6  HBASE-26875 RpcRetryingCallerImpl translateException ignores 
return value of recursive call (#4270)
3a90de6 is described below

commit 3a90de63a2a033ea5ce0eb3a9476f1b4b9d06970
Author: Bryan Beaudreault <[email protected]>
AuthorDate: Fri Mar 25 12:05:12 2022 -0400

    HBASE-26875 RpcRetryingCallerImpl translateException ignores return value 
of recursive call (#4270)
    
    Signed-off-by: Andrew Purtell <[email protected]>
---
 .../hadoop/hbase/client/RpcRetryingCallerImpl.java |  7 ++-
 .../hbase/client/RpcRetryingCallerImplTest.java    | 50 ++++++++++++++++++++++
 2 files changed, 53 insertions(+), 4 deletions(-)

diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerImpl.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerImpl.java
index fb58bfa..2a7dc5f 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerImpl.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerImpl.java
@@ -224,13 +224,12 @@ public class RpcRetryingCallerImpl<T> implements 
RpcRetryingCaller<T> {
     if (t instanceof ServiceException) {
       ServiceException se = (ServiceException)t;
       Throwable cause = se.getCause();
-      if (cause != null && cause instanceof DoNotRetryIOException) {
+      if (cause instanceof DoNotRetryIOException) {
         throw (DoNotRetryIOException)cause;
       }
       // Don't let ServiceException out; its rpc specific.
-      t = cause;
-      // t could be a RemoteException so go around again.
-      translateException(t);
+      // It also could be a RemoteException, so go around again.
+      t = translateException(cause);
     } else if (t instanceof DoNotRetryIOException) {
       throw (DoNotRetryIOException)t;
     }
diff --git 
a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/RpcRetryingCallerImplTest.java
 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/RpcRetryingCallerImplTest.java
new file mode 100644
index 0000000..0291bb7
--- /dev/null
+++ 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/RpcRetryingCallerImplTest.java
@@ -0,0 +1,50 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+package org.apache.hadoop.hbase.client;
+
+import org.apache.hadoop.hbase.CallDroppedException;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.ipc.RemoteWithExtrasException;
+import org.apache.hadoop.hbase.testclassification.ClientTests;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
+
+@Category({ ClientTests.class, SmallTests.class})
+public class RpcRetryingCallerImplTest {
+
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+    HBaseClassTestRule.forClass(RpcRetryingCallerImplTest.class);
+
+  @Test
+  public void itTranslatesRemoteExceptionFromServiceException() throws 
DoNotRetryIOException {
+    String message = "CDE for test";
+    ServiceException exception = new ServiceException(
+      new RemoteWithExtrasException(CallDroppedException.class.getName(), 
message, false));
+
+    Throwable result = RpcRetryingCallerImpl.translateException(exception);
+    Assert.assertTrue("Expect unwrap CallDroppedException",
+      result instanceof CallDroppedException);
+    Assert.assertEquals(message, result.getMessage());
+  }
+}

Reply via email to