fix: Scanner resource leak in SqlFileBasedSource.fetchNextBatch#18467
Conversation
yihua
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.
LGTM — clean, minimal fix for a real resource leak. Converting to try-with-resources correctly ensures the Scanner (and its underlying FSDataInputStream) is closed on both normal and exceptional exit paths.
|
Pinging for committer approval. This PR fixes a genuine |
CI Build Failures — Master Branch Issue (not this PR)The Evidence:
The CI situation is being tracked. Once the master build stabilises, a re-run of CI on this PR should pass. cc @vinothchandrasekar @alexeykudinkin @danny0405 @nsivabalan — would appreciate a re-run once the master build issue is resolved. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18467 +/- ##
============================================
+ Coverage 66.50% 68.86% +2.35%
- Complexity 22910 28238 +5328
============================================
Files 2004 2460 +456
Lines 112236 135260 +23024
Branches 14250 16392 +2142
============================================
+ Hits 74645 93141 +18496
- Misses 31087 34748 +3661
- Partials 6504 7371 +867
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Friendly reminder: CI is green on this PR. @vinothchandrasekar @alexeykudinkin @danny0405 @nsivabalan — would appreciate a review and approval when you get a chance! |
Describe the issue this Pull Request addresses
In
SqlFileBasedSource.fetchNextBatch(), aScannerobject created to read the SQL source file is never explicitly closed. This causes a file descriptor leak on every batch fetch invocation.Summary and Changelog
Fixed a
Scannerresource leak inSqlFileBasedSource.fetchNextBatch()by wrapping theScannerin a try-with-resources block, ensuring it is always closed regardless of whether an exception is thrown.new Scanner(...)assignment with a try-with-resources statement so theScanneris closed after the batch is read.Impact
No public API or user-facing change. Prevents file descriptor leaks in long-running streaming jobs using
SqlFileBasedSource.Risk Level
low — Only affects resource cleanup; no functional SQL reading logic changed.
Documentation Update
none
Contributor's checklist