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

   ## Issue
   [CAMEL-24530](https://issues.apache.org/jira/browse/CAMEL-24530)
   
   ## Problem
   `DJLConverter` opens a stream from `File`/`Path` bodies and never closes it:
   
   ```java
   public static Image toImage(File file) throws IOException {
       return toImage(new FileInputStream(file));   // stream never closed
   }
   ```
   
   The same applies to `toImage(Path)`, `toAudio(File)` and `toAudio(Path)`. 
The `InputStream` overload
   they delegate to reads the image/audio via `ImageFactory` / `AudioFactory` 
`fromInputStream(...)`,
   which does **not** close the stream. Every conversion of a `File` or `Path` 
body therefore leaks a
   file descriptor — under load (a file/FTP route feeding DJL) this exhausts 
the process's descriptors.
   
   ## Fix
   Wrap the self-opened stream in try-with-resources in the four `File`/`Path` 
converter methods so the
   descriptor is always released after the image/audio has been read into 
memory. The `InputStream`
   overloads are intentionally left unchanged: they receive a **caller-owned** 
stream and must not close
   it.
   
   ## Testing
   - New `DJLConverterTest` verifies `toImage(File)` and `toImage(Path)` return 
a valid image (exercising
     the try-with-resources path). The audio methods are structurally identical.
   - `mvn -Psourcecheck validate` green.
   
   _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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to