Federico Mariani created CAMEL-24123:
----------------------------------------

             Summary: camel-smb: recursive=true with readLock=changed never 
consumes files in sub-directories - relative path is passed as SMB search 
pattern
                 Key: CAMEL-24123
                 URL: https://issues.apache.org/jira/browse/CAMEL-24123
             Project: Camel
          Issue Type: Bug
          Components: camel-smb
    Affects Versions: 4.21.0
            Reporter: Federico Mariani
         Attachments: SmbRecursiveChangedReadLockIssueIT.java

h3. Problem
{{SmbExclusiveReadLockCheck.getSmbFiles}} 
(SmbExclusiveReadLockCheck.java:81-90) lists the file's parent directory using 
{{file.getFileName()}} as the server-side search pattern:
{code:java}
String path = file.getParent();
if (operations instanceof SmbOperations smbOperations) {
    return smbOperations.listFiles(path, file.getFileName());   // relative 
path, not a name
}
{code}
{{SmbConsumer.asGenericFile}} sets {{fileName}} to the path *relative to the 
endpoint directory* - for {{smb:host/share/data?recursive=true}} and a file 
{{data/sub/hello.txt}}, {{getFileName()}} is {{sub/hello.txt}} while 
{{getParent()}} is {{data/sub}}. An SMB QueryDirectory search pattern must be a 
plain name/wildcard; a pattern containing a path separator matches nothing (or 
errors, server-dependent). The lock check therefore always sees {{newLength=0 < 
minLength}} and the read lock is never acquired: every file in a sub-directory 
is skipped after the full {{readLockTimeout}}, on every poll. 
{{file.getFileNameOnly()}} - which the match loop two lines below already uses 
- is what should be passed.

h3. Failure scenario
{{smb://...?recursive=true&readLock=changed}} - top-level files are consumed 
normally, files in any sub-directory are never consumed; each one burns the 
whole readLockTimeout per poll before being skipped, so polls also become 
pathologically slow.

h3. Reproducer
Attached failing IT (place in 
{{components/camel-smb/src/test/java/org/apache/camel/component/smb/}}): a file 
written to {{changedrecursive/sub/hello.txt}} is never delivered to the mock, 
while the identical flat layout works.
----
_This issue was researched and filed by Claude Code on behalf of [~fmariani] 
(GitHub: Croway), as part of a deep code review of camel-smb. A failing JUnit 
reproducer is attached; it fails deterministically on current main 
(4.22.0-SNAPSHOT) against the Samba testcontainer used by the existing 
camel-smb ITs._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to