atiaomar1978-hub opened a new pull request, #24916: URL: https://github.com/apache/camel/pull/24916
## CAMEL-24190 — Full Summary (with Assumptions) **Jira:** https://issues.apache.org/jira/browse/CAMEL-24190 **Title:** camel-file - GenericFileOnCompletion should support SynchronizationVetoable handover for stream download **Type / Priority / Status:** Improvement · Major · Open **Component:** camel-file **Labels:** improvement --- ### Problem (from Jira) `GenericFileOnCompletion` implements plain `Synchronization`. With `streamDownload=true` and an async downstream endpoint (e.g. `seda:`, `jms:`), on-completion runs on the **consumer poll thread** and closes the stream via `releaseRetrievedFileResources()` before the downstream route reads it. **Affected components:** camel-file, camel-ftp, camel-sftp, camel-smb (and related remote file consumers). --- ### Fix (implemented in `C:\c\camel-24190-fix`) `GenericFileOnCompletion` implements `SynchronizationVetoable`: - `allowHandover()` → `endpoint.isStreamDownload()` - `beforeHandover()` → noop Added `isStreamDownload()`: - `GenericFileEndpoint` — default `false` - `RemoteFileEndpoint` — delegates to `RemoteFileConfiguration.isStreamDownload()` (FTP/SFTP/FTPS/Azure Files) - `SmbEndpoint` — delegates to `SmbConfiguration.isStreamDownload()` --- ### Assumptions (based on Jira + implementation) 1. **Handover is enabled only when `streamDownload=true`** Jira describes `allowHandover() = true` for the stream-download case. We interpret that as **conditional**, not unconditional: non-stream routes keep existing on-completion timing (no handover). 2. **Local `file:` consumer is out of scope** Jira focuses on streamed remote downloads. Local `FileEndpoint` has no `streamDownload` option, so `isStreamDownload()` stays `false` and behavior is unchanged. 3. **Remote endpoints are covered via inheritance** FTP/SFTP/FTPS/Azure Files use `RemoteFileEndpoint`; SMB overrides explicitly. No separate change per protocol module beyond that. 4. **Existing disconnect synchronizations are unchanged** FTP/SMB `disconnect` callbacks keep `allowHandover() = false` so disconnect still runs on the consumer thread. 5. **Deferred completion is acceptable for stream download** Jira notes that handover can delay commit/rollback and keep file handles/connections open while downstream queues are busy. We accept that tradeoff for `streamDownload=true` only. 6. **SEDA handover path is the primary fix target** Tests simulate async routing via `DefaultUnitOfWork.handoverSynchronization()` and `ExchangeHelper.createCorrelatedCopy()` (same mechanism SEDA uses). No embedded FTP/SFTP integration test was added. 7. **Upgrade guide entry is sufficient for user-visible behavior** Documented in `camel-4x-upgrade-guide-4_22.adoc` under stream download + async endpoints. 8. **Jira wording vs Camel internals** Jira states plain `Synchronization` “does not support handover.” In current Camel, non-vetoable synchronizations default to handover allowed in `DefaultUnitOfWork`. The practical bug is stream completion firing too early on the poll thread; implementing `SynchronizationVetoable` with an explicit stream-download gate matches the intended fix regardless of that wording. --- ### Files Changed | File | Change | |------|--------| | `GenericFileOnCompletion.java` | `SynchronizationVetoable` + handover methods | | `GenericFileEndpoint.java` | `isStreamDownload()` default | | `RemoteFileEndpoint.java` | override `isStreamDownload()` | | `SmbEndpoint.java` | override `isStreamDownload()` | | `GenericFileOnCompletionHandoverTest.java` | new (6 tests) | | `camel-file/pom.xml` | test deps (mockito, camel-core-languages) | | `camel-4x-upgrade-guide-4_22.adoc` | behavior note | --- ### Test Coverage — all passed | Suite | Tests | Result | |-------|------:|--------| | `GenericFileOnCompletionHandoverTest` | 6 | pass | | `camel-file` (full) | 25 | pass | | `camel-core` file consumer sample | 4 | pass | --- ### Git Status | Item | Value | |------|-------| | **Worktree** | `C:\c\camel-24190-fix` | | **Branch** | `CAMEL-24190-streamdownload-handover` | | **Commit / push** | Not done yet | -- 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]
