Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle deadends #15

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,21 @@ public <T> T invokeRemoteMethod(InvocationDescriptor invocationDescriptor) throw
}
}

public void completeInvocation(InvocationResponse invocationResponse) {
public boolean completeInvocation(InvocationResponse invocationResponse) {
// do we have a pending invocation for this invocation id?
PendingInvocation<?> pendingInvocation = pendingInvocations.get(invocationResponse.getInvocationId());
if (pendingInvocation == null) {
throw new IllegalStateException("No pending invocation found for invocation id " + invocationResponse.getInvocationId() + ". Data: " + invocationResponse.getResult());
//return;
// we cannot handle this invocation, so it must be handled in another listener
return false;
}

pendingInvocation.complete(invocationResponse.getResult());

// remove the pending invocation from the map
pendingInvocations.remove(invocationResponse.getInvocationId());

// invocation was successfully completed
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public TransportHandler(

private boolean handleInvocationResponse(byte[] bytes) throws ClassNotFoundException {
InvocationResponse invocationResponse = InvocationResponse.fromBytes(serializer, bytes);
outgoingInvocationTracker.completeInvocation(invocationResponse);
return true;
return outgoingInvocationTracker.completeInvocation(invocationResponse);
}

private boolean handleInvocationRequest(byte[] bytes) throws ClassNotFoundException {
Expand Down