You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/10/13 06:54:00 UTC

[jira] [Created] (CAMEL-25600) camel-telegram - an interrupted send does not cancel the HTTP request, so its connection is not released

Claus Ibsen created CAMEL-25600:
-----------------------------------

             Summary: camel-telegram - an interrupted send does not cancel the HTTP request, so its connection is not released
                 Key: CAMEL-25600
                 URL: https://issues.apache.org/jira/browse/CAMEL-25600
             Project: Camel
          Issue Type: Bug
          Components: camel-telegram
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Follow-up of CAMEL-25577 (PR #27761), found in review.

{{TelegramMessageHandler}} waits on {{response}}, which is the {{thenApply}} stage of the future returned by {{HttpClient.sendAsync}}. On interrupt it calls {{response.cancel(true)}}, but cancelling a dependent stage does not cancel the source future, so the HTTP request keeps going. When its answer arrives the handler is skipped, and the {{ofInputStream()}} body is never read or closed, so the connection is not released.

Since Java 16 the {{HttpClient}} aborts the exchange when the future returned by {{sendAsync}} is cancelled. Keep that future and cancel it:

{code:java}
CompletableFuture<HttpResponse<InputStream>> sent = apiClient.client().sendAsync(...);
CompletableFuture<Object> response = sent.thenApply(telegramAsyncHandler::handleCompressedResponse);
...
sent.cancel(true);
{code}

Only matters on interrupt (for example a forced shutdown).

_Claude Code on behalf of Claus Ibsen_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)