Croway opened a new pull request, #29286: URL: https://github.com/apache/camel/pull/29286
[CAMEL-26337](https://issues.apache.org/jira/browse/CAMEL-26337) ### What was wrong The ftp, ftps, sftp, mina-sftp and azure-files endpoints inherit the `readLock` option, and its 8-value enum, from the file component. Their process strategy factories only build a read lock for `none`/`false`, `rename` and `changed`, and return `null` for every other value, with no log line. So `readLock=idempotent-changed`, `markerFile`, `fileLock`, `idempotent`, `idempotent-rename`, or a misspelled value such as `chnaged`, was accepted and the consumer ran without any read lock. It could then pick up a file that was still being uploaded. The file and smb endpoints already reject a value they do not implement (`readLockCheck()` in `FileEndpoint` and `SmbEndpoint`); `RemoteFileEndpoint` had no such check. The remote endpoints also listed options that only apply to read locks of the file component and do nothing there: `readLockDeleteOrphanLockFiles`, `readLockRemoveOnCommit` and `readLockRemoveOnRollback` on all of them and on smb, plus the four `readLockIdempotentRelease*` options on sftp and mina-sftp (ftp, ftps, azure-files and smb already excluded those four). ### What changed - `RemoteFileEndpoint.createConsumer()` checks `readLock`, as `SmbEndpoint` does. `none`, `rename` and `changed` are accepted, and `false` and `off` are accepted as `none`. Any other value throws `IllegalArgumentException: ReadLock invalid: <value>, must be one of: none,rename,changed`. One change covers ftp, ftps, sftp, mina-sftp and azure-files, including `poll`/`pollEnrich`, which create the consumer through `GenericFilePollingConsumer`. scp is producer-only and unaffected. - The check is skipped when a custom `exclusiveReadLockStrategy` or `processStrategy` is set, as `readLock` does not apply then. - `@Metadata(excludeProperties=...)` drops the options that do nothing: the three above on `FtpEndpoint`, `FtpsEndpoint`, `SftpEndpoint`, `MinaSftpEndpoint`, `FilesEndpoint` and `SmbEndpoint` (in smb only `FileProcessStrategyFactory` reads them, and the smb read locks ignore them), and the four `readLockIdempotentRelease*` options on `SftpEndpoint` and `MinaSftpEndpoint`. scp does not list any of them. - The smb check itself is unchanged. ### Tests - New unit tests: `RemoteFileEndpointReadLockTest` (camel-ftp: ftp, ftps and sftp), `MinaSftpEndpointReadLockTest` and `FilesEndpointReadLockTest`. They cover the unsupported values (consumer and polling consumer), the accepted values and the read lock they give, the skip with a custom `exclusiveReadLockStrategy`/`processStrategy`, and a producer on a URI with an unsupported value. - On main, with the old `RemoteFileEndpoint`: 20 of 44, 6 of 14 and 5 of 10 fail ("Expected IllegalArgumentException to be thrown, but nothing was thrown"). With the fix all pass. - Unit suites with the fix: camel-ftp, camel-mina-sftp, camel-azure-files, camel-smb and camel-jsch pass. ### Docs and upgrade guide - The ftp (limitations section), ftps, sftp, mina-sftp and azure-files pages say which read locks are supported, that `false` and `off` mean `none`, that any other value fails when the consumer is created, and that the check is skipped with a custom strategy. The smb page says which read locks smb supports. - `camel-4x-upgrade-guide-4_24.adoc`: the new failure and the values still accepted, the removed options per component, and that Java Endpoint DSL code calling the removed builder methods no longer compiles. An endpoint URI that sets a removed option still resolves: the value is set on the endpoint and has no effect, and the catalog endpoint validation now reports it as unknown. - Regenerated: the `src/generated` JSON, configurers and URI factories of the touched components, the catalog JSON and doc copies, and the six endpoint DSL builder factories. The component DSL is unchanged. ### Backport Not a backport candidate: it turns a value that was silently ignored into a failure at consumer creation, and removes Endpoint DSL methods, so it is for 4.24 only. ### Reviewers Suggested: `davsclaus` (asked for this fix on the JIRA) and `gnodet` (active on camel-ftp). _Claude Code on behalf of Federico Mariani_ -- 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]
