wmedvede commented on code in PR #2194:
URL:
https://github.com/apache/incubator-kie-kogito-apps/pull/2194#discussion_r1963699857
##########
data-index/data-index-common/src/main/java/org/kie/kogito/index/api/KogitoRuntimeCommonClient.java:
##########
@@ -116,13 +117,20 @@ public CompletableFuture
sendDeleteClientRequest(WebClient webClient, String req
return future;
}
- protected void
asyncHttpResponseTreatment(AsyncResult<HttpResponse<Buffer>> res,
CompletableFuture future, String logMessage) {
- if (res.succeeded() && (res.result().statusCode() == 200 ||
res.result().statusCode() == 201)) {
- String jsonMessage = res.result().bodyAsString();
+ protected void
asyncHttpResponseTreatment(AsyncResult<HttpResponse<Buffer>> res,
CompletableFuture<String> future, String logMessage) {
+ asyncHttpResponseTreatment(res, future, result -> {
+ String jsonMessage = result.bodyAsString();
LOGGER.trace("Result {}", jsonMessage);
- future.complete(jsonMessage != null ? jsonMessage : "Successfully
performed: " + logMessage);
+ return jsonMessage != null ? jsonMessage : "Successfully
performed: " + logMessage;
+ }, logMessage);
+
+ }
+
+ protected <T> void
asyncHttpResponseTreatment(AsyncResult<HttpResponse<Buffer>> res,
CompletableFuture<T> future, Function<HttpResponse<Buffer>, T> function, String
logMessage) {
+ if (res.succeeded() && (res.result().statusCode() == 200 ||
res.result().statusCode() == 201)) {
+ future.complete(function.apply(res.result()));
} else {
- LOGGER.trace("Error {}", logMessage);
+ LOGGER.info("Error {}", logMessage);
Review Comment:
If we are logging an error, why not to use do LOGGER.error ?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]