allthingssecurity commented on code in PR #27694:
URL: https://github.com/apache/camel/pull/27694#discussion_r4245775464
##########
components/camel-whatsapp/src/main/java/org/apache/camel/component/whatsapp/service/WhatsAppServiceRestAPIAdapter.java:
##########
@@ -197,8 +198,17 @@ public void sendMessage(Exchange exchange, AsyncCallback
callback, T message, St
CompletableFuture<HttpResponse<String>> asyncResponse
= httpClient.sendAsync(httpRequestBuilder.build(),
HttpResponse.BodyHandlers.ofString());
- asyncResponse.thenAccept(response -> {
+ // whenComplete (and not thenAccept), so that the exchange is also
completed when there is no response,
+ // for example when the connection failed or the connect timeout
expired. The request itself has no
+ // timeout, so a server that accepts the connection and never
answers is not covered here.
+ asyncResponse.whenComplete((response, failure) -> {
try {
+ if (failure != null) {
+ exchange.setException(
+ failure instanceof CompletionException &&
failure.getCause() != null
Review Comment:
Applied in e3219fe23c73. I checked the claim with a small program: a refused
connection gives
`java.net.ConnectException` with a null message. The failure is now
`new RuntimeCamelException("Could not send message to " +
URISupport.sanitizeUri(uri), cause)`. The access token is
sent in the `Authorization` header and is not in the URI; the URI is
sanitized anyway, as `baseUri` is a user
option. The test asserts the message with the URI and
`hasCauseInstanceOf(IOException.class)`.
_Claude Code on behalf of allthingssecurity_
--
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]