wmedvede commented on code in PR #2214:
URL: 
https://github.com/apache/incubator-kie-kogito-apps/pull/2214#discussion_r2093576518


##########
jobs-service/jobs-recipients/job-recipient-common-http/src/main/java/org/kie/kogito/job/recipient/common/http/HTTPRequestExecutor.java:
##########
@@ -78,44 +79,63 @@ public WebClient createClient() {
         return WebClient.create(vertx);
     }
 
-    public Uni<JobExecutionResponse> execute(JobDetails jobDetails) {
-        return Uni.createFrom().item(jobDetails)
-                .chain(job -> {
-                    final R recipient = getRecipient(job);
-                    final String limit = getLimit(job);
-                    final HTTPRequest request = buildRequest(recipient, limit);
-                    final long requestTimeout = getTimeoutInMillis(job);
-                    return executeRequest(request, requestTimeout)
-                            .onFailure().transform(unexpected -> new 
JobExecutionException(job.getId(),
-                                    "Unexpected error when executing HTTP 
request for job: " + jobDetails.getId() + ". " + unexpected.getMessage()))
-                            .onItem().transform(response -> 
JobExecutionResponse.builder()
-                                    .message(response.bodyAsString())
-                                    
.code(String.valueOf(response.statusCode()))
-                                    .now()
-                                    .jobId(job.getId())
-                                    .build())
-                            .chain(this::handleResponse);
-                });
+    public JobExecutionResponse execute(JobDetails jobDetails) {
+        try {
+            R recipient = getRecipient(jobDetails);
+            String limit = getLimit(jobDetails);
+            HTTPRequest request = buildRequest(recipient, limit);
+            long requestTimeout = getTimeoutInMillis(jobDetails);
+            HttpResponse<?> response = executeRequest(request, requestTimeout);
+            JobExecutionResponse jobExecutionResponse = 
JobExecutionResponse.builder()
+                    .message(response.bodyAsString())
+                    .code(String.valueOf(response.statusCode()))
+                    .now()
+                    .jobId(jobDetails.getId())
+                    .build();
+
+            return this.handleResponse(jobExecutionResponse);
+        } catch (Throwable unexpected) {
+            LOGGER.error("Executing error for {}", jobDetails.getId(), 
unexpected);

Review Comment:
   Shadows a potential unexpected error. And also the potential translation of 
the http response with an error to  JobExecutionException exception in 
handleResponse.
   
   Must be like this:
   
   If totally unexpected error, we must create and throw a new 
JobExecutionException. 
   
   If the handleResponse throws JobExecutionException, that exception must be 
propagated
   
   



-- 
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]

Reply via email to