Repository navigation
Hoist common OSProcess fields + add Solaris/AIX /proc base - #3390
Conversation
Two cross-platform OSProcess dedups: - Hoist the 13 uniform attribute fields (name, path, state, parentProcessID, threadCount, priority, virtualSize, kernelTime, userTime, startTime, upTime, bytesRead, bytesWritten) and their trivial getters into AbstractOSProcess. Declared protected (with a VisibilityModifier suppression) so each platform's updateAttributes() keeps assigning them directly. Removed from all six per-OS bases (Linux, Windows, macOS, BSD, Solaris, AIX). macOS keeps its historical empty-string name default via its constructor. - Add AbstractProcOSProcess (oshi.software.common.os.unix) for the /proc-struct readers Solaris and AIX, sharing getCurrentWorkingDirectory, fd-count getOpenFiles, pflags getBitness, the /proc/<pid>/lwp thread skeleton (via a createThread hook; AIX now implements it concretely), the command-line backup fallback, and the user/group/resident-memory accessors. Fixes a pre-existing AIX bug: getCurrentWorkingDirectory built "/proc" + pid (missing the slash) instead of "/proc/" + pid; the shared base uses the correct path. Left per-OS: updateAttributes, getAffinityMask, thread factories, args/env plumbing, and the (genuinely divergent) state-char mappings. Net -452 LOC. Validated locally on macOS via NativeComparisonTest (39/39, JNA==FFM); Linux/Windows via PR CI, BSD/Solaris via unix.yaml, AIX via cfarm.
|
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)
✅ Files skipped from review due to trivial changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
📝 WalkthroughWalkthroughThis PR refactors OS process attribute handling across multiple platforms by moving common process attributes and their getter implementations from duplicate code in platform-specific classes into shared abstract base classes. ChangesOS Process Attribute Abstraction
Possibly related PRs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Hoisting kernelTime/userTime/upTime into AbstractOSProcess as fields caused the test double's captured constructor params of the same name to be shadowed by the new inherited fields: inside the anonymous subclass, the bare name 'upTime' resolved to the inherited field (0) rather than the captured param, so getProcessCpuLoadCumulative computed 0.0 instead of the expected value. Rename the createProcess params (kernelTimeArg/userTimeArg/upTimeArg) to remove the collision. Test-only; behavior unchanged.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3390 +/- ##
============================================
- Coverage 75.14% 75.13% -0.01%
- Complexity 76 2443 +2367
============================================
Files 578 579 +1
Lines 21455 21397 -58
Branches 3560 3560
============================================
- Hits 16122 16077 -45
+ Misses 3307 3293 -14
- Partials 2026 2027 +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:
|
Summary
Two cross-platform
OSProcessdeduplications (the per-OS bases all extendAbstractOSProcess):AbstractOSProcess—name,path,state,parentProcessID,threadCount,priority,virtualSize,kernelTime,userTime,startTime,upTime,bytesRead,bytesWritten. Declaredprotected(with aVisibilityModifiersuppression) so each platform'supdateAttributes()keeps assigning them directly — no setter churn. Removed from all six bases (Linux, Windows, macOS, BSD, Solaris, AIX). macOS preserves its historical empty-stringnamedefault via its constructor.AbstractProcOSProcess(oshi.software.common.os.unix) for the/proc-struct readers Solaris and AIX, sharinggetCurrentWorkingDirectory, fd-countgetOpenFiles,pflagsgetBitness, the/proc/<pid>/lwpthread skeleton (via acreateThreadhook; AIX now implements it concretely), the command-line backup fallback, and the user/group/resident-memory accessors.Fixes a pre-existing AIX bug:
getCurrentWorkingDirectorybuilt"/proc" + pid(missing the slash) instead of"/proc/" + pid; the shared base uses the correct path.Deliberately left per-OS (genuine divergence):
updateAttributes,getAffinityMask, thread factories, args/env container plumbing, and the state-char mappings (Rmeans RUNNING on Linux/BSD but WAITING on Solaris; macOS uses ints).Test plan
NativeComparisonTest(JNA==FFM) on macOS: 39/39 (coverscurrentProcess,currentProcessUpdateAttributes, threads)unix.yml; AIX via cfarmSummary by CodeRabbit
Refactor
New Features