Fix FTP/SFTP listener not triggering when fileNamePattern is not specified#1548
Fix FTP/SFTP listener not triggering when fileNamePattern is not specified#1548niveathika merged 2 commits intomasterfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughFixes FTP/SFTP listener behavior so fileNamePattern is only validated/used when explicitly provided; pattern assignment is skipped when empty, and directory filtering applies only when a pattern is set. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
147daa7 to
2521c30
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@native/src/main/java/io/ballerina/stdlib/ftp/transport/server/RemoteFileSystemConsumer.java`:
- Around line 265-278: The recursive directory traversal in
RemoteFileSystemConsumer leaves intermediate FileObject instances open; after
obtaining childFileObject = child.getChildren() and after recursion via
handleDirectory(childFileObject), ensure you call child.close() in a finally
block (or use a safeClose helper) to release the intermediate directory
resource, and also explicitly close each FileObject contained in childFileObject
after processing them (or have handleDirectory close its entries) to avoid
leaking remote filesystem handles; update the code around child.getChildren(),
handleDirectory(...) and closeDirectories() to perform these explicit closes
(use FileObject.close()/closeQuietly as appropriate).
native/src/main/java/io/ballerina/stdlib/ftp/transport/server/RemoteFileSystemConsumer.java
Outdated
Show resolved
Hide resolved
…ified
When no fileNamePattern was provided, the listener would not trigger
for any files. This was caused by:
Empty string default: When fileNamePattern was not specified, it
defaulted to an empty string "". Since `"filename".matches("")`
returns false for any non-empty filename, all files were filtered out.
Fix:
- Only add fileNamePattern to params if it's non-null and non-empty.
When absent, RemoteFileSystemConsumer.fileNamePattern remains null,
and the filter correctly allows all files through.
Fixes wso2/product-ballerina-integrator#656
2521c30 to
e4c1328
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
changelog.md (1)
2-2:⚠️ Potential issue | 🟡 MinorPre-existing documentation error: Incorrect package name.
Line 2 references "Ballerina Email package" but this changelog documents changes to the Ballerina FTP package. This is a pre-existing error that should be corrected for accuracy.
📝 Proposed fix
-This file contains all the notable changes done to the Ballerina Email package through the releases. +This file contains all the notable changes done to the Ballerina FTP package through the releases.
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (76.61%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1548 +/- ##
============================================
+ Coverage 75.76% 76.61% +0.84%
- Complexity 822 1043 +221
============================================
Files 60 76 +16
Lines 4168 4823 +655
Branches 701 837 +136
============================================
+ Hits 3158 3695 +537
- Misses 703 756 +53
- Partials 307 372 +65 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|



Summary
fileNamePatternconfiguration is not specifiedRoot Cause
When no
fileNamePatternwas provided, the listener would not trigger for any files because:Empty string default: When
fileNamePatternwas not specified, it defaulted to an empty string"". Since"filename".matches("")returnsfalsefor any non-empty filename in Java, all files were filtered out.Fix
fileNamePatternto params if it's non-null and non-empty (making it truly optional)RemoteFileSystemConsumer.fileNamePatternremainsnull, and the filter correctly allows all files throughFixes wso2/product-ballerina-integrator#656
Test plan
fileNamePattern- should trigger for all filesfileNamePatternspecified - should only trigger for matching files/directories🤖 Generated with Claude Code
Summary
This PR fixes an issue where FTP/SFTP listeners did not trigger when the optional fileNamePattern configuration was omitted. The change ensures listeners behave correctly both when a pattern is absent and when a pattern is specified.
Changes Made
Outcome