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

   ## Summary
   
   Fixes [CAMEL-24563](https://issues.apache.org/jira/browse/CAMEL-24563).
   
   When stream caching attempts to convert a `RemoteFile` to `StreamCache` and 
the file body has not been loaded from the remote server, 
`GenericFileConverter.convertTo()` silently returns `null` with no diagnostic 
information. Operators see stream caching silently skipped with no log message 
to explain why.
   
   ## Root cause
   
   `GenericFile.getBody()` returns `null` when the remote file content was not 
retrieved before conversion. In Camel 4, the NPE from Camel 3.x is already 
guarded (returns `null` safely), but no log message was emitted.
   
   **Stack trace (Camel 3.x where NPE was thrown):**
   ```
   StreamCacheException: Error during type conversion from type: RemoteFile to 
StreamCache
     due to TypeConversionException: ... due to java.lang.NullPointerException: 
null
       at CamelInternalProcessor$StreamCachingAdvice.before
       at GenericFileConsumer.processExchange
   Caused by: java.lang.NullPointerException
   ```
   
   ## Fix
   
   Add a `WARN` log in `GenericFileConverter.convertTo()` when `file.getBody()` 
is null, including the filename and configuration guidance:
   
   ```
   WARN Cannot convert GenericFile 'CPP_B2BUnits_196498_20260829_094325.xml' to 
org.apache.camel.StreamCache
        because the file body has not been loaded. The remote file content was 
not retrieved before stream caching.
        Check your SFTP/FTP consumer configuration (localWorkDirectory, 
streamDownload).
   ```
   
   This is a **diagnostic/observability improvement only** — no behavior change.
   
   ## Changes
   
   - 
`components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileConverter.java`
 — add WARN log when body is null
   - `GenericFileConverterNullBodyTest.java` (new) — 2 tests: no NPE on null 
body, null returned
   
   ## Test Results
   
   ```
   Tests run: 2, Failures: 0, Errors: 0  [JDK 21]
   Full camel-file suite: BUILD SUCCESS
   ```
   
   ## AI Attribution
   
   _Claude Code on behalf of mayurbm_
   
   ```
   Co-authored-by: Claude Sonnet 4.5 <[email protected]>
   ```


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