Skip to content
Merged
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
37 changes: 14 additions & 23 deletions sdk/src/main/java/io/dapr/client/DaprClientHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,20 @@ public <T> Mono<Response<T>> invokeMethod(InvokeServiceRequest invokeServiceRequ
byte[] serializedRequestBody = objectSerializer.serialize(request);
Mono<DaprHttp.Response> response = this.client.invokeApi(httMethod, path,
httpExtension.getQueryString(), serializedRequestBody, metadata, context);
return response.flatMap(r -> {
try {
T object = objectSerializer.deserialize(r.getBody(), type);
if (object == null) {
return Mono.empty();
}
return response.flatMap(r -> getMono(type, r)).map(r -> new Response<>(context, r));
} catch (Exception ex) {
return DaprException.wrapMono(ex);
}
}

return Mono.just(object);
} catch (Exception ex) {
return DaprException.wrapMono(ex);
}
}).map(r -> new Response<>(context, r));
private <T> Mono<T> getMono(TypeRef<T> type, DaprHttp.Response r) {
try {
T object = objectSerializer.deserialize(r.getBody(), type);
if (object == null) {
return Mono.empty();
}

return Mono.just(object);
} catch (Exception ex) {
return DaprException.wrapMono(ex);
}
Expand Down Expand Up @@ -258,18 +260,7 @@ public <T> Mono<Response<T>> invokeBinding(InvokeBindingRequest request, TypeRef
String httpMethod = DaprHttp.HttpMethods.POST.name();
Mono<DaprHttp.Response> response = this.client.invokeApi(
httpMethod, url.toString(), null, payload, null, context);
return response.flatMap(r -> {
try {
T object = objectSerializer.deserialize(r.getBody(), type);
if (object == null) {
return Mono.empty();
}

return Mono.just(object);
} catch (Exception ex) {
return DaprException.wrapMono(ex);
}
}).map(r -> new Response<>(context, r));
return response.flatMap(r -> getMono(type, r)).map(r -> new Response<>(context, r));
} catch (Exception ex) {
return DaprException.wrapMono(ex);
}
Expand Down