Skip to content

Commit

Permalink
HBASE-26875 RpcRetryingCallerImpl translateException ignores return v…
Browse files Browse the repository at this point in the history
…alue of recursive call (apache#4270)

Signed-off-by: Andrew Purtell <apurtell@apache.org>
  • Loading branch information
bbeaudreault authored and apurtell committed Mar 25, 2022
1 parent 83d5a9e commit 3a90de6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
Expand Up @@ -224,13 +224,12 @@ static Throwable translateException(Throwable t) throws DoNotRetryIOException {
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;
}
Expand Down
@@ -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());
}
}

0 comments on commit 3a90de6

Please sign in to comment.