Skip to content

Commit

Permalink
Fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindgamesnl committed Aug 24, 2023
1 parent 47dfab4 commit 3785581
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
9 changes: 7 additions & 2 deletions rpcnis-core/src/main/java/com/rpcnis/core/Rpcnis.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.util.Timer;
import java.util.UUID;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ConcurrentHashMap;

public class Rpcnis {
Expand Down Expand Up @@ -51,7 +52,7 @@ public Rpcnis(RpcTransport transport) {
this(new RpcOptions(), new GsonSerializer(), transport);
}

public <T> T invoke(InvocationDescriptor invocationDescriptor, Class<T> returnType) throws InvocationTimedOutException {
public <T> T invoke(InvocationDescriptor invocationDescriptor, Class<T> returnType) throws Throwable {
// create a pending invocation
PendingInvocation<T> pendingInvocation = new PendingInvocation<>(this, invocationDescriptor, () -> {
// remove the pending invocation from the map
Expand All @@ -64,7 +65,11 @@ public <T> T invoke(InvocationDescriptor invocationDescriptor, Class<T> returnTy
// TODO: transmit

// wait for response or timeout
return pendingInvocation.waitForResponse();
try {
return pendingInvocation.waitForResponse();
} catch (CompletionException e) {
throw e.getCause();
}
}

public void completeInvocation(InvocationDescriptor invocationDescriptor, Object value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public ProxyInvocHandler(Rpcnis rpcnis, String targetName) {
}

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws InvocationTimedOutException {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// build invocation descriptor
Class<?>[] argTypes = new Class<?>[args.length];
for (int i = 0; i < args.length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void tearDown() {
}

@Test
public void testPendingInvocation() {
public void testPendingInvocation() throws Throwable {
// base instance
Rpcnis rpcnis = new Rpcnis(new LoopbackTransport());

Expand All @@ -47,7 +47,6 @@ public void testPendingInvocation() {
});

String response = rpcnis.invoke(invocationDescriptor, String.class);

assert response.equals(testString);
}

Expand Down

0 comments on commit 3785581

Please sign in to comment.