Repository navigation
Make the Linux nullability contracts honest - #3634
Conversation
Ninth step of draining oshi-core and oshi-core-ffm. Covers the Linux hardware, file-system, process and login-session components in both implementations. All of it is declarations catching up with contracts that oshi-common already states: queryStatvfs is documented as returning null on failure and declared long @nullable [] in the abstract base, enumerateCpuSyspathsViaUdev the same for a system without udev, and getProcess for a process that is not running, which OperatingSystem has always declared @nullable. The Linux disk enumerator takes a null store to mean "enumerate every disk" rather than refresh one, which is how its own no-argument overload calls it, and the FFM session reader reports a session it cannot read with null, which its caller skips. WhoJNA needed an explicit null test the analyzer could read. The existing guard, nativeValue(ttyPointer) != 0, was already correct: JNA's Pointer.nativeValue returns 0 for a null pointer in 5.18.1, the version this project uses. So the added ttyPointer != null is redundant at runtime and exists only to make that invariant visible; it changes no behavior. Part of #3593.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
📜 Recent review details⏰ Context from checks skipped due to timeout. (7)
🧰 Additional context used📓 Path-based instructions (5)**/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{java,xml,md}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*Test.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/test/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core-ffm/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (8)📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
📚 Learning: 2026-07-30T00:35:22.638ZApplied to files:
📚 Learning: 2026-08-03T00:46:14.953ZApplied to files:
📚 Learning: 2026-08-15T14:25:48.170ZApplied to files:
📚 Learning: 2026-08-15T15:43:29.296ZApplied to files:
📚 Learning: 2026-08-15T15:59:20.875ZApplied to files:
📚 Learning: 2026-08-02T23:56:23.866ZApplied to files:
🔇 Additional comments (13)
📝 WalkthroughWalkthroughThe change adds JSpecify ChangesLinux native nullability and validation
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to This PR aligns Linux nullability declarations and adjusts flaky comparison assertions without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review. 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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3634 +/- ##
============================================
- Coverage 79.98% 79.91% -0.08%
- Complexity 3863 4100 +237
============================================
Files 697 697
Lines 24275 24275
Branches 4006 4006
============================================
- Hits 19417 19400 -17
- Misses 2719 2738 +19
+ Partials 2139 2137 -2
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:
|
Ninth step of draining
oshi-coreandoshi-core-ffm. Covers the Linux hardware, file-system,process and login-session components in both implementations. Reactor findings 94 → 70 measured
against
master; this branch is cut frommasterrather than stacked on #3633, so the two areindependent and can land in either order.
Declarations catching up with contracts oshi-common already states
queryStatvfsis documented as returning null on failure and declaredlong @Nullable []in theabstract base.
enumerateCpuSyspathsViaUdevlikewise, for a system without udev.getProcessfor a process that is not running, whichOperatingSystemhas always declared@Nullable.one, which is how its own no-argument overload calls it.
One guard the analyzer could not read
WhoJNAtested its pointers withnativeValue(ttyPointer) != 0, which was already correct:JNA's
Pointer.nativeValuereturns 0 for a null pointer in 5.18.1, the version this project uses.The added
ttyPointer != nullis redundant at runtime and exists only to make that invariantvisible. Worth stating precisely, because the JNA jar that happens to sit in a local
~/.m2may be3.4.0, where that method dereferences
p.peerwith no null check — checking the version actually inuse is what turns this from "bug fix" into "no-op".
Also: three flaky comparison assertions
Unrelated to the marking, but folded in here rather than spending another push cycle. The
OpenIndiana job failed on:
Context switches are cumulative and the FFM snapshot is taken second, so it can never be the lower
of the two — the same shape as the
kernelTimeanduserTimeassertions immediately above, whichalready use
isGreaterThanOrEqualTo. A ratio bound is unusable: a JVM accumulates thousands ofswitches per second and this test runs on one only seconds old, so 20% amounts to requiring the two
snapshots be under half a second apart. All three context-switch assertions are converted to the
ordering form, which still catches the wrong-field or wrong-process binding they exist to detect.
The system-wide counter at
processorContextSwitchesAndInterruptskeeps its 0.01 ratio; it has notflaked.
This failure is not related to #3633 — Solaris context switches come from
/proc/<pid>/usage(
pr_vctx/pr_ictx) inSolarisOSProcess, which that PR does not touch.No behavior change
No CHANGELOG entry. Verified by diffing against master and cancelling every line whose only
difference is an annotation: 11 of the 12 source files have zero residue, the twelfth being the
WhoJNAguard above.Full gate on macOS:
spotless:apply sortpom:sort spotless:check checkstyle:check install forbiddenapis:check javadoc:javadocplus-Perror-prone clean install. All modules green, 1561tests, 0 failures. This is Linux code, so nothing here is verified beyond compilation and CI.
Part of #3593.
Summary by CodeRabbit
Bug Fixes
Tests