Parker Mauney created CAMEL-26337:
-------------------------------------

             Summary: camel-ftp - readLock=idempotent, idempotent-changed and 
idempotent-rename are accepted on FTP/FTPS/SFTP endpoints but produce no read 
lock
                 Key: CAMEL-26337
                 URL: https://issues.apache.org/jira/browse/CAMEL-26337
             Project: Camel
          Issue Type: Bug
          Components: camel-ftp, camel-sftp
    Affects Versions: 4.23.0, 4.22.2
            Reporter: Parker Mauney


The {{readLock}} option on the ftp, ftps and sftp endpoints shares its metadata 
with {{{}GenericFileEndpoint{}}}, so the published enum is the file 
component's: {{{}none, markerFile, fileLock, rename, changed, idempotent, 
idempotent-changed, idempotent-rename{}}}. The text marks the three 
{{idempotent*}} values "(only for file component)", but 
{{FtpProcessStrategyFactory}} and {{SftpProcessStrategyFactory}} only build a 
lock for {{{}none{}}}, {{rename}} and {{changed}} and return {{null}} for 
anything else, with no warning or validation error.

So an SFTP consumer with {{readLock=idempotent-changed}} (and, say, 
{{{}readLockCheckInterval=100&readLockTimeout=5000{}}}) runs with no read lock 
at all and downloads files as soon as they are listed, including files still 
being uploaded (truncated at a 16 KB boundary) and files that are still 0 
bytes. Nothing in the logs says the lock is missing.

Reproducer (camel-4.23.0):
{code:java}
Map<String, Object> params = Map.of("readLock", "idempotent-changed");
GenericFileProcessStrategy<FTPFile> strategy =
        new FtpProcessStrategyFactory().createGenericFileProcessStrategy(new 
DefaultCamelContext(), params);
GenericFileExclusiveReadLockStrategy<FTPFile> lock =
        ((GenericFileProcessStrategySupport<FTPFile>) 
strategy).getExclusiveReadLockStrategy();
assertNotNull(lock); // null; "changed" gives 
FtpChangedExclusiveReadLockStrategy
{code}
Same for {{{}SftpProcessStrategyFactory{}}}, {{idempotent}} and 
{{{}idempotent-rename{}}}. 

Expected: endpoint creation fails (or at least warns) when {{readLock}} names a 
strategy the remote component does not implement. It would also help to limit 
the enum in the ftp/ftps/sftp metadata to {{none, rename, changed}} so the 
docs, the endpoint DSL and {{camel validate}} stop advertising the file-only 
values.

I know the idempotent locks are file-only by design (found in a users@ thread 
from Nov 2020, and the CAMEL-25016 PR notes). This is concerned with the silent 
acceptance and the component docs. Happy to send a PR for the validation if 
that is the preferred fix.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to