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

[PR] CAMEL-24488: camel-ibm-watson-speech-to-text - close the audio FileInputStream opened by the producer [camel]

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

   # CAMEL-24488: close the audio FileInputStream in the Watson STT producer
   
   `WatsonSpeechToTextProducer.recognize()` opens a `FileInputStream` for the audio input — from the `CamelIbmWatsonSttAudioFile` header (a `File`) or from a `File` message body — but never closes it. There is no `try`/`finally` or try-with-resources around `stt.recognize(options).execute()`, so on every File-based invocation (and on any exception during recognition) the file descriptor is leaked.
   
   ## Fix
   
   Track an `ownStream` flag, set to `true` only for the two producer-opened `FileInputStream` cases, and close the stream via `IOHelper.close` in a `finally` block around the recognition. When the audio is supplied as an exchange-body `InputStream`, the caller owns it, so it is deliberately left untouched.
   
   ## Testing
   
   The module ships only integration tests (they require live Watson credentials); this is a resource-lifecycle fix around an SDK call that cannot be unit-tested without new mocking dependencies. Verified with a module build (`BUILD SUCCESS`, no generated-file drift).
   
   ---
   _Claude Code on behalf of oscerd_
   


-- 
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-24488: camel-ibm-watson-speech-to-text - close the audio FileInputStream opened by the producer [camel]

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


-- 
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-24488: camel-ibm-watson-speech-to-text - close the audio FileInputStream opened by the producer [camel]

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

   :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-24488: camel-ibm-watson-speech-to-text - close the audio FileInputStream opened by the producer [camel]

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

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-ibm/camel-ibm-watson-speech-to-text`
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **38 affected modules** (current approach: 9).
   
   <details><summary>:warning: Modules only in Scalpel (29)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-catalog`
   - `camel-catalog-console`
   - `camel-catalog-lucene`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-componentdsl`
   - `camel-csimple-maven-plugin`
   - `camel-endpointdsl`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `docs`
   - `dummy-component`
   
   </details>
   
   **Skip-tests mode would test 9 modules** (1 direct + 8 downstream), **skip tests for 29** (generated code, meta-modules)
   
   <details><summary>Modules Scalpel would test (9)</summary>
   
   - `camel-ibm-watson-speech-to-text`
   - `camel-jbang-mcp`
   - `camel-jbang-plugin-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>
   
   <details><summary>Modules with tests skipped (29)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-catalog`
   - `camel-catalog-console`
   - `camel-catalog-lucene`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-componentdsl`
   - `camel-csimple-maven-plugin`
   - `camel-endpointdsl`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `docs`
   - `dummy-component`
   
   </details>
   
   > :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
   
   </details>
   
   <details><summary>All tested modules (38 modules)</summary>
   
   - Camel :: All Components Sync point
   - Camel :: Assembly
   - Camel :: Catalog :: CSimple Maven Plugin (deprecated)
   - Camel :: Catalog :: Camel Catalog
   - Camel :: Catalog :: Camel Report Maven Plugin
   - Camel :: Catalog :: Camel Route Parser
   - Camel :: Catalog :: Console
   - Camel :: Catalog :: Dummy Component
   - Camel :: Catalog :: Lucene (deprecated)
   - Camel :: Catalog :: Maven
   - Camel :: Catalog :: Suggest
   - Camel :: Component DSL
   - Camel :: Coverage
   - Camel :: Docs
   - Camel :: Endpoint DSL
   - Camel :: Endpoint DSL :: Support
   - Camel :: IBM :: Watson Speech to Text
   - Camel :: Integration Tests
   - Camel :: JBang :: Core
   - Camel :: JBang :: Integration tests
   - Camel :: JBang :: MCP
   - Camel :: JBang :: Main
   - Camel :: JBang :: Plugin :: Edit
   - Camel :: JBang :: Plugin :: Generate
   - Camel :: JBang :: Plugin :: Kubernetes
   - Camel :: JBang :: Plugin :: MCP
   - Camel :: JBang :: Plugin :: Route Parser
   - Camel :: JBang :: Plugin :: TUI
   - Camel :: JBang :: Plugin :: Testing
   - Camel :: JBang :: Plugin :: Validate
   - Camel :: Kamelet Main
   - Camel :: Launcher
   - Camel :: Launcher :: Container
   - Camel :: YAML DSL
   - Camel :: YAML DSL :: Deserializers
   - Camel :: YAML DSL :: Maven Plugins
   - 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/32931770829)


-- 
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-24488: camel-ibm-watson-speech-to-text - close the audio FileInputStream opened by the producer [camel]

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


##########
components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducer.java:
##########
@@ -100,15 +101,18 @@ private void recognize(Exchange exchange) throws Exception {
         // Get audio input from header or body
         File audioFile = exchange.getIn().getHeader(WatsonSpeechToTextConstants.AUDIO_FILE, File.class);
         InputStream audioStream = null;
+        boolean ownStream = false;

Review Comment:
   Non-blocking question: per the project's Code Quality guidance, bug fixes should generally include a regression test, and this one doesn't (reasonably explained in the PR body — the module has no unit-testable path into `recognize()` without a live Watson client, and adding Mockito purely for this fix would be a new test dependency needing its own justification). That trade-off seems fine for a one-line leak fix. Just flagging in case there's an appetite for adding Mockito to this module down the line so leak-style fixes get regression coverage — or if "verified by module build + manual reasoning" is accepted practice for `camel-ibm-*` producers today.



-- 
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-24488: camel-ibm-watson-speech-to-text - close the audio FileInputStream opened by the producer [camel]

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


##########
components/camel-ibm/camel-ibm-watson-speech-to-text/src/main/java/org/apache/camel/component/ibm/watson/stt/WatsonSpeechToTextProducer.java:
##########
@@ -100,15 +101,18 @@ private void recognize(Exchange exchange) throws Exception {
         // Get audio input from header or body
         File audioFile = exchange.getIn().getHeader(WatsonSpeechToTextConstants.AUDIO_FILE, File.class);
         InputStream audioStream = null;
+        boolean ownStream = false;

Review Comment:
   Thanks — agreed. Today the camel-ibm-* producer modules are integration-test-only (no Mockito), so "verified by module build + manual reasoning" is the accepted practice for this kind of resource-lifecycle fix, and pulling in Mockito solely for a one-line leak fix wasn't justified here. Adding Mockito to give these modules unit-test coverage for leak/lifecycle fixes is a reasonable follow-up if there's appetite — happy to file it separately.
   
   _Claude Code on behalf of oscerd_



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