Repository navigation
Unify FileSystem file-descriptor methods behind common bases (JNA/FFM dedup) - #3445
Conversation
… dedup) First subsystem in the cross-OS consistency audit. Hoist the file-descriptor query methods to common base classes so the JNA/FFM subclasses shrink to a single native hook, matching the pattern FreeBsdFileSystem already used: - macOS: MacFileSystem base gains the three FD methods + a querySysctl(String) hook; MacFileSystemJNA/FFM drop to the one-line sysctl call. - OpenBSD: same treatment on OpenBsdFileSystem. - Windows: new WindowsFileSystem base holds MAX_WINDOWS_HANDLES + the FD methods behind a queryHandles() hook; JNA/FFM extend it. No user-facing behavior change. The FFM Windows handle limit had hardcoded the 64-bit value while JNA computed it conditionally, but FFM runs only on 64-bit Windows (JDK 25+) where the values coincide; the shared base uses the conditional form to keep both backends consistent. The native getFileStores volume enumeration stays per-backend (Kernel32/WMI vs getfsstat are genuinely different native code); its JNA/FFM merge-loop drift is deferred to a follow-up (coupled to the static WindowsOSFileStore updateAttributes calls).
📝 WalkthroughWalkthroughThe change centralizes file-descriptor reporting for macOS, OpenBSD, and Windows. Shared filesystem classes implement descriptor getters, while JNA and FFM subclasses provide native sysctl or handle-count queries. ChangesFile-descriptor reporting
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3445 +/- ##
============================================
- Coverage 74.52% 74.47% -0.06%
Complexity 76 76
============================================
Files 580 581 +1
Lines 21945 21944 -1
Branches 3670 3669 -1
============================================
- Hits 16355 16343 -12
- Misses 3552 3564 +12
+ Partials 2038 2037 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
First subsystem in the cross-OS consistency/dedup audit. No user-facing behavior change — pure structural consolidation.
What
Hoist the file-descriptor query methods (
getOpenFileDescriptors/getMaxFileDescriptors/getMaxFileDescriptorsPerProcess) into common base classes so the JNA/FFM subclasses shrink to a single native hook — matching the patternFreeBsdFileSystemalready used (base implements the public methods, subclass provides one native call).MacFileSystemgains the 3 FD methods + aquerySysctl(String)hooksysctlOpenBsdFileSystemsame treatmentsysctlWindowsFileSystembase holdsMAX_WINDOWS_HANDLES+ FD methods behind aqueryHandles()hookNet −29 lines, and five platforms are now structurally uniform on the FreeBSD hook pattern.
Notes
getFileStoresvolume enumeration stays per-backend (Kernel32/WMI vsgetfsstatare genuinely different native code, not mergeable without abstracting the whole native layer). Its JNA/FFM merge loop has a real drift (order handling + description enrichment differ), but hoisting it is coupled to thestaticWindowsOSFileStore.updateAttributescalls and needs a Windows-tested decision — split out to a follow-up.Part of the subsystem-by-subsystem audit; more platforms/subsystems to follow.
Summary by CodeRabbit
New Features
Improvements