Skip to content

Commit 1373e11

Browse files
committed
Don't use reflection where not necessary in TestClientTokenUtil
1 parent d1979be commit 1373e11

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

hbase-client/src/test/java/org/apache/hadoop/hbase/security/token/TestClientTokenUtil.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import static org.junit.Assert.assertSame;
2222
import static org.junit.Assert.fail;
2323

24+
import com.google.protobuf.ServiceException;
2425
import java.io.IOException;
2526
import java.lang.reflect.Field;
26-
import java.lang.reflect.InvocationTargetException;
2727
import java.net.URL;
2828
import java.net.URLClassLoader;
2929
import java.util.concurrent.CompletableFuture;
@@ -73,10 +73,9 @@ public void testObtainToken() throws Exception {
7373
shouldInjectFault.set(null, injected);
7474

7575
try {
76-
clientTokenUtil.getMethod("obtainToken", Connection.class)
77-
.invoke(null, new Object[] { null });
76+
ClientTokenUtil.obtainToken((Connection)null);
7877
fail("Should have injected exception.");
79-
} catch (InvocationTargetException e) {
78+
} catch (IOException e) {
8079
Throwable t = e;
8180
boolean serviceExceptionFound = false;
8281
while ((t = t.getCause()) != null) {
@@ -90,8 +89,7 @@ public void testObtainToken() throws Exception {
9089
}
9190
}
9291

93-
CompletableFuture<?> future = (CompletableFuture<?>) clientTokenUtil
94-
.getMethod("obtainToken", AsyncConnection.class).invoke(null, new Object[] { null });
92+
CompletableFuture<?> future = ClientTokenUtil.obtainToken((AsyncConnection)null);
9593
try {
9694
future.get();
9795
fail("Should have injected exception.");

0 commit comments

Comments
 (0)