You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "Croway (via GitHub)" <gi...@apache.org> on 2026/05/26 14:10:53 UTC

[PR] camel-openai: close OpenAI client on endpoint stop to prevent OkHttp thread leak [camel]

Croway opened a new pull request, #23531:
URL: https://github.com/apache/camel/pull/23531

   ## Summary
   
   - Call `client.close()` in `OpenAIEndpoint.doStop()` before nulling the reference so that OkHttp's dispatcher executor, connection pool, and cache are properly shut down.
   - Without this, OkHttp threads (`OkHttp Dispatcher`, `OkHttp ConnectionPool`) linger after route stop, especially visible under `exec:java` or Camel JBang dev mode where the JVM does not exit.
   
   ## Test plan
   
   - [ ] Verify `mvn verify` passes on the `camel-openai` module
   - [ ] Start a route using the openai component, stop it, and confirm no OkHttp threads remain in a thread dump


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] camel-openai: close OpenAI client on endpoint stop to prevent OkHttp thread leak [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #23531:
URL: https://github.com/apache/camel/pull/23531#discussion_r3304908626


##########
components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java:
##########
@@ -138,6 +138,7 @@ protected void doStop() throws Exception {
             returnDirectTools.clear();
         }
         if (client != null) {
+            client.close();

Review Comment:
   ```
   Closes this client, relinquishing any underlying resources.
   This is purposefully not inherited from AutoCloseable because the client is long-lived and usually should not be synchronously closed via try-with-resources.
   ```
   
   this is from the .close() java doc, should be safe without a try catch



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] camel-openai: close OpenAI client on endpoint stop to prevent OkHttp thread leak [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23531:
URL: https://github.com/apache/camel/pull/23531#issuecomment-4544923235

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: Apache Camel Committers, please review the following items:
   
     * First-time contributors **require MANUAL approval** for the GitHub Actions to run
     * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
     * You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
     * Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] camel-openai: close OpenAI client on endpoint stop to prevent OkHttp thread leak [camel]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #23531:
URL: https://github.com/apache/camel/pull/23531#discussion_r3304879384


##########
components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java:
##########
@@ -138,6 +138,7 @@ protected void doStop() throws Exception {
             returnDirectTools.clear();
         }
         if (client != null) {
+            client.close();

Review Comment:
   Should we enclose in a try catch as it is done for the mcp clients?



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] camel-openai: close OpenAI client on endpoint stop to prevent OkHttp thread leak [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23531:
URL: https://github.com/apache/camel/pull/23531#issuecomment-4545103087

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-ai/camel-openai`
   
   :warning: **Some tests are disabled on GitHub Actions** (`@DisabledIfSystemProperty(named = "ci.env.name")`) and require manual verification:
   
   - `components/camel-ai/camel-openai`: 6 test(s) disabled on GitHub Actions
   
   <details><summary>All tested modules (8 modules)</summary>
   
   - Camel :: AI :: OpenAI
   - Camel :: JBang :: MCP
   - Camel :: JBang :: Plugin :: Route Parser
   - Camel :: JBang :: Plugin :: TUI
   - Camel :: JBang :: Plugin :: Validate
   - Camel :: Launcher :: Container
   - Camel :: YAML DSL :: Validator
   - Camel :: YAML DSL :: Validator Maven Plugin
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/26453440110)


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] camel-openai: close OpenAI client on endpoint stop to prevent OkHttp thread leak [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway merged PR #23531:
URL: https://github.com/apache/camel/pull/23531


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org