davsclaus commented on code in PR #23567:
URL: https://github.com/apache/camel/pull/23567#discussion_r3312088852


##########
components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java:
##########
@@ -84,17 +84,17 @@ private boolean sendMessageByToken(Exchange exchange, 
AsyncCallback callback) {
                 slackMessage.setText(exchange.getIn().getBody(String.class));
                 response = sendLegacySlackMessage(slackMessage);
             }
+            if (!response.isOk()) {
+                exchange.setException(
+                        new CamelExchangeException("Error POSTing to Slack 
API: " + response, exchange));
+            }
         } catch (Exception e) {
             exchange.setException(e);
             return true;
         } finally {
             callback.done(true);
         }
 
-        if (!response.isOk()) {
-            exchange.setException(new CamelExchangeException("Error POSTing to 
Slack API: " + response.toString(), exchange));
-        }
-
         return false;

Review Comment:
   This should be `return true` — `SlackProducer` is fully synchronous and 
`callback.done(true)` is called in the `finally` block above. Returning `false` 
incorrectly signals async completion.
   
   ```suggestion
           return true;
   ```



##########
components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackProducer.java:
##########
@@ -134,17 +134,17 @@ private boolean sendMessageByWebhookURL(Exchange 
exchange, AsyncCallback callbac
         WebhookResponse response;
         try {
             response = slack.send(slackEndpoint.getWebhookUrl(), json);
+            if (response.getCode() < 200 || response.getCode() > 299) {
+                exchange.setException(
+                        new CamelExchangeException("Error POSTing to Slack 
API: " + response, exchange));
+            }
         } catch (IOException e) {
             exchange.setException(e);
             return true;
         } finally {
             callback.done(true);
         }
 
-        if (response.getCode() < 200 || response.getCode() > 299) {
-            exchange.setException(new CamelExchangeException("Error POSTing to 
Slack API: " + response.toString(), exchange));
-        }
-
         return false;

Review Comment:
   Same here — should be `return true` to match the synchronous 
`callback.done(true)` above.
   
   ```suggestion
           return true;
   ```



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

Reply via email to