Repository navigation
Dedup BSD OSProcess open-file-limit, cwd, and bitness logic - #3465
Conversation
Hoist the shared getrlimit-based open-file-limit skeleton and ELF-bitness parsing into BsdOSProcess, and the byte-identical current-working-directory and open-file delegations into the FreeBSD/OpenBSD/DragonFly bases. The JNA and FFM twins now keep only their irreducible native bits: a queryRlimitNofile getrlimit hook, a one-line queryOwnProcessId, and the genuinely divergent argument/environment queries (FreeBSD/DragonFly bitness reuse elfBitness). OpenBSD (no procfs) overrides the non-current-process limit fallback to -1. NetBSD is unchanged: it fully overrides the limit methods, so the new BsdOSProcess concrete defaults never affect it. Adds a portable BsdOSProcessTest covering the limit-routing skeleton and elfBitness parsing, plus the os.unix.bsd opens line in module-info.test.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (3)
📜 Recent review details⏰ Context from checks skipped due to timeout. (10)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
🔇 Additional comments (1)
📝 WalkthroughWalkthroughBSD process classes now share open-file limit routing and ELF bitness parsing. DragonFlyBSD, FreeBSD, and OpenBSD platform classes provide filesystem queries, while FFM and JNA backends implement native process-ID and RLIMIT_NOFILE hooks. ChangesBSD process query consolidation
Estimated code review effort: 4 (Complex) | ~45 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 #3465 +/- ##
============================================
- Coverage 75.14% 75.12% -0.03%
Complexity 76 76
============================================
Files 587 587
Lines 21604 21576 -28
Branches 3611 3608 -3
============================================
- Hits 16235 16209 -26
+ Misses 3393 3390 -3
- Partials 1976 1977 +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:
|
getCwdMap (and FreeBSD's parseCwdMap helper it delegated to) had no production caller — the OSProcess bases resolve the working directory per process via getCwd, not via a bulk PID-to-cwd map. Drop the dead methods and the tests that only exercised them.
Part of the cross-OS consistency/dedup audit (OSProcess subsystem, BSD family).
The BSD
OSProcessJNA and FFM twins duplicated a lot of non-native logic. This hoists the shared pieces without changing behavior:BsdOSProcess: thegetSoftOpenFileLimit/getHardOpenFileLimitskeleton (if current process → getrlimit, else → fallback) plus anelfBitness(String)helper, exposed via three overridable hooks (queryOwnProcessId,queryRlimitNofile,otherProcessOpenFileLimit). The hook defaults keep NetBSD — which overrides the limit methods directly — completely unaffected.getCurrentWorkingDirectory/getOpenFilesdelegations move here (4 twin copies → 1 base each). These stay per-platform because each delegates to a differentprocstat/fstatutil with a different output format. OpenBSD (no procfs) overrides the non-current-process fallback to-1.queryRlimitNofilegetrlimithook, a one-linequeryOwnProcessId, and the genuinely divergent argument/environment queries. FreeBSD and DragonFly bitness now reuseelfBitness.Adds a portable
BsdOSProcessTest(limit-routing skeleton +elfBitnessparsing) and theos.unix.bsdopens line inmodule-info.test.No CHANGELOG entry: pure dedup with identical observable behavior.
Local gate: spotless, checkstyle, forbiddenapis, javadoc, and a clean full-reactor build all pass; oshi-common tests including the new test pass. BSD native / JNA==FFM parity validated via the unix.yaml FreeBSD/OpenBSD/DragonFly VMs (dispatched manually, since unix.yaml does not trigger on pull requests).
Summary by CodeRabbit