-
Notifications
You must be signed in to change notification settings - Fork 14
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
Change InvokeMethod() to return UMessage #74
Conversation
* @param responseFuture CompletionStage<UPayload> response from uTransport. | ||
* @param expectedClazz The class name of the declared expected return type of the RPC method. | ||
* @return Returns a CompletionStage containing the declared expected return type of the RPC method or an exception. | ||
* @param <T> The declared expected return type of the RPC method. | ||
*/ | ||
static <T extends Message> CompletionStage<T> mapResponse(CompletionStage<UPayload> responseFuture, Class<T> expectedClazz) { | ||
return responseFuture.handle((payload, exception) -> { | ||
static <T extends Message> CompletionStage<T> mapResponse(CompletionStage<UMessage> responseFuture, Class<T> expectedClazz) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we are not returning a UPayload, I think it would be better to rename expectedClazz to expectedPayloadClazz
I know it is Class and T represents the Message that is the payload, but I still think this can add a lot of clarity.
code is read more than it is written
static <T extends Message> CompletionStage<T> mapResponse(CompletionStage<UPayload> responseFuture, Class<T> expectedClazz) { | ||
return responseFuture.handle((payload, exception) -> { | ||
static <T extends Message> CompletionStage<T> mapResponse(CompletionStage<UMessage> responseFuture, Class<T> expectedClazz) { | ||
return responseFuture.handle((message, exception) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call it uMessage so as not to be confused with Message of protobuf since the class type is not in the code
// Unexpected exception | ||
if (exception != null) { | ||
throw new CompletionException(exception.getMessage(), exception); | ||
} | ||
if (payload == null) { | ||
if (message == null || !message.hasPayload()) { | ||
throw new RuntimeException("Server returned a null payload. Expected " + expectedClazz.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the case where the payload only contains default values - like a UStatus that contains OK, there were times that the payload serialized to empy - there were times I got an empty string.
Are there tests to check this exception.
In addition, the exception could be clearer - UMessage payload is empty, expected payload of type expectedClazz.getName()
#73