Repository navigation
Hoist common OSThread fields and getters into AbstractOSThread - #3446
Conversation
Second subsystem in the cross-OS consistency audit. Every OSThread implementation declared the same thread-attribute fields (threadId, name, state, kernel/user/start/up time, priority, faults, context switches, start address) with identical return-the-field getters. Hoist them into AbstractOSThread as protected fields + getters (the AbstractOSProcess field-hoist model), so each platform keeps only its own parsing: - AbstractOSThread: gains the 12 protected fields + field-backed getters. - Linux/AIX/Solaris/BSD/Windows/Mac OSThread: drop the fields + getters, keep their parsing/constructors (Linux keeps its os field, Solaris its memoized psinfo suppliers, Windows its getProcName + perf-counter updateAttributes, BSD its ps-row parsing). - BsdOSThread's protected fields (already the full superset) moved up; its checkstyle VisibilityModifier suppression migrated to AbstractOSThread. Net -279 lines. getName() is now uniformly null-safe (returns empty per the interface contract) instead of each platform differing; no observable change for valid threads.
|
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 (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (16)
🔇 Additional comments (1)
📝 WalkthroughWalkthrough
ChangesThread attribute centralization
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
The test's anonymous AbstractOSThread overrode getters returning captured parameters named threadId/kernelTime/etc. Now that AbstractOSThread declares inherited protected fields of the same names, those unqualified references resolved to the (zero) fields instead of the captured params, so every getter returned 0. Set the protected fields directly instead (the test is in the same package), which also exercises the real field-backed getters.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3446 +/- ##
============================================
- Coverage 74.54% 74.44% -0.11%
Complexity 76 76
============================================
Files 581 581
Lines 21944 21903 -41
Branches 3669 3669
============================================
- Hits 16358 16305 -53
- Misses 3549 3556 +7
- Partials 2037 2042 +5
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:
|
Second subsystem in the cross-OS consistency/dedup audit. Pure structural consolidation — no observable change for valid threads.
What
Every
OSThreadimplementation declared the same 12 thread-attribute fields (threadId,name,state, kernel/user/start/up time,priority, minor/major faults, context switches, start address) with identicalreturn this.fieldgetters. This hoists them intoAbstractOSThreadasprotectedfields + field-backed getters — the same field-hoist modelAbstractOSProcessalready uses — so each platform keeps only its own parsing inupdateAttributes().AbstractOSThreadprotectedfields + the gettersLinux/AIX/Solaris/BSD/Windows/MacOSThreadPlatform-specific bits stay put: Linux's
osfield, Solaris's memoizedpsinfo/prusagesuppliers, Windows'sgetProcName()+ perf-counterupdateAttributes(procName, pcb), BSD'sps-row parsing.BsdOSThread'sprotectedfields (already the full superset) simply moved up a level, and its checkstyleVisibilityModifiersuppression migrated toAbstractOSThread.Net −279 lines (8 files, +93/−372).
Note
getName()is now uniformly null-safe in the base (name != null ? name : ""), matching the interface's documented default of""and what Solaris already did. Previously Windows/Linux could returnnullfor an invalid/unset thread; they now return"". Not a change for any valid thread, and it aligns to the contract — flagging it for transparency, not treating it as user-facing.Deferred (from the map)
lwpsinfostructs genuinely differ (field count/order/types), so the flagged "twin" can't merge its parser — only a ~30-line JNA buffer-read helper is shareable, and it's really OSProcess plumbing. Folding that into the OSProcess PR (OSX: Yosemite: hw.availcpu is not defined #8) instead.Part of the subsystem-by-subsystem audit; follows #3445 (FileSystem).
Summary by CodeRabbit
Refactor
Tests
Chores