tzulitai commented on a change in pull request #177:
URL: https://github.com/apache/flink-statefun/pull/177#discussion_r529224501
##########
File path:
statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/reqreply/RequestReplyFunction.java
##########
@@ -125,8 +126,44 @@ private void onAsyncResult(
sendToFunction(context, batch);
return;
}
- InvocationResponse invocationResult =
unpackInvocationOrThrow(context.self(), asyncResult);
- handleInvocationResponse(context, invocationResult);
+ if (asyncResult.failure()) {
+ throw new IllegalStateException(
+ "Failure forwarding a message to a remote function " +
context.self(),
+ asyncResult.throwable());
+ }
+
+ final Either<InvocationResponse, IncompleteInvocationContext> response =
+ unpackResponse(asyncResult.value());
+ if (response.isRight()) {
+ handleIncompleteInvocationContextResponse(context, response.right(),
asyncResult.metadata());
+ } else {
+ handleInvocationResultResponse(context, response.left());
+ }
+ }
+
+ private static Either<InvocationResponse, IncompleteInvocationContext>
unpackResponse(
Review comment:
I've tested this before (also with a message serialization round-trip)
and it looks like if a `oneof` field was not set, then getting either one of
the type values would return the type's default instance, i.e.:
if `fromFunction.hasInvocationResult()` is `false`, then the object returned
by `fromFunction.getInvocationResult` equals
`InvocationResult.getDefaultInstance()`. The get method would not throw.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]