Skip to content

Comments

Add File Content Listener#1499

Merged
niveathika merged 26 commits intoballerina-platform:masterfrom
SachinAkash01:file-content-listener
Oct 31, 2025
Merged

Add File Content Listener#1499
niveathika merged 26 commits intoballerina-platform:masterfrom
SachinAkash01:file-content-listener

Conversation

@SachinAkash01
Copy link
Member

@SachinAkash01 SachinAkash01 commented Oct 10, 2025

Purpose

$subject

The current ftp:Listener reports file add/delete events via onFileChange, exposing metadata only. To process content, developers must invoke a client (Caller->get) inside the handler.
This PR adds content-first callbacks to the existing listener, so services can receive file content directly (stream, bytes, text, JSON, XML, CSV) as soon as a file is detected.

Fixes: ballerina-platform/ballerina-library#1490

Examples

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 11.20815% with 610 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.13%. Comparing base (c0f8de8) to head (102d800).
⚠️ Report is 27 commits behind head on master.

Files with missing lines Patch % Lines
...stdlib/ftp/plugin/FtpContentFunctionValidator.java 0.00% 132 Missing ⚠️
...a/stdlib/ftp/server/FtpContentCallbackHandler.java 0.00% 131 Missing ⚠️
...ballerina/stdlib/ftp/util/FtpContentConverter.java 0.00% 91 Missing ⚠️
...ina/stdlib/ftp/plugin/FtpFileDeletedValidator.java 0.00% 85 Missing ⚠️
...va/io/ballerina/stdlib/ftp/server/FtpListener.java 18.84% 52 Missing and 4 partials ⚠️
...llerina/stdlib/ftp/server/ContentMethodRouter.java 14.75% 50 Missing and 2 partials ⚠️
...llerina/stdlib/ftp/plugin/FtpServiceValidator.java 27.02% 15 Missing and 12 partials ⚠️
...lerina/stdlib/ftp/util/FtpFileExtensionMapper.java 0.00% 15 Missing ⚠️
...ain/java/io/ballerina/stdlib/ftp/util/FtpUtil.java 52.17% 6 Missing and 5 partials ⚠️
...ballerina/stdlib/ftp/server/FtpListenerHelper.java 47.36% 6 Missing and 4 partials ⚠️

❌ Your project status has failed because the head coverage (62.13%) 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    #1499       +/-   ##
=============================================
- Coverage     81.78%   62.13%   -19.65%     
- Complexity      272      392      +120     
=============================================
  Files            30       45       +15     
  Lines          1510     2525     +1015     
  Branches        194      416      +222     
=============================================
+ Hits           1235     1569      +334     
- Misses          197      812      +615     
- Partials         78      144       +66     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@niveathika niveathika added the Skip GraalVM Check This will skip the GraalVM compatibility check label Oct 31, 2025
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
8.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@niveathika
Copy link
Contributor

@SachinAkash01 I am merging this as it is urgent for the release, Lets track the disabled tests in different issue.

@niveathika niveathika merged commit 1ef435b into ballerina-platform:master Oct 31, 2025
5 of 8 checks passed
Copy link
Contributor

@niveathika niveathika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Module md file needs to be updated with latest docs

MethodType methodType = methodTypeOpt.get();

// Fetch file content
byte[] fileContent = fetchFileContentFromRemote(fileInfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For stream use cases, we shouldn't read the entire content to memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip GraalVM Check This will skip the GraalVM compatibility check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a File content listener to the FTP module

2 participants