Repository navigation
Return 0 for unavailable CPU temperature everywhere, and make IPConnection.getState() non-null - #3781
Conversation
…ction.getState() non-null Sensors.getCpuTemperature() was documented as "0 or NaN" when unavailable. Only FreeBSD (both backends) returned NaN; AbstractSensors now maps a NaN reading to 0 before memoizing, so every implementation reports the single sentinel the package documentation describes. IPConnection.getState() was @nullable and documented to return null for UDP or an unknown state, but no implementation ever passed null: UDP rows carry TcpState.NONE and unrecognized states TcpState.UNKNOWN. The getter is now non-null, and the public constructor normalizes a null argument to UNKNOWN.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (8)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (14)
🧰 Additional context used📚 Code guidelines (2)📓 Path-based instructions (3)Source excerpt: `oshi-core-ffm` may not reference `com.sun.jna.**`.📄 CodeRabbit inference engine (AGENTS.md) Files:
Source excerpt: `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any `System.load`/`loadLibrary`.📄 CodeRabbit inference engine (AGENTS.md) Files:
Source excerpt: The Changelog lets users know what's changed.📄 CodeRabbit inference engine (CONTRIBUTING.md) Files:
🔇 Additional comments (1)
📝 WalkthroughWalkthroughThe changes normalize unavailable CPU temperature results to zero and update related documentation and tests. They also make ChangesCPU temperature fallback
IP connection state
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Unavailable CPU temperatures return zero through the public getter, and unknown IP connection states return UNKNOWN. The supplied evidence shows these changes align with their documented contracts, with no established merge risk. Pre-merge checks |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3781 +/- ##
============================================
- Coverage 80.40% 80.30% -0.11%
- Complexity 83 370 +287
============================================
Files 722 722
Lines 25917 25920 +3
Branches 4376 4378 +2
============================================
- Hits 20838 20814 -24
- Misses 2850 2872 +22
- Partials 2229 2234 +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:
|
Part of the sentinel-convention sweep that follows #3767: getters whose documented or actual sentinel differed from the convention in the
oshi.hardware/oshi.software.ospackage docs.Sensors.getCpuTemperature()was documented as "0 or NaN". FreeBSD (JNA and FFM) returned NaN; every other platform returned 0.AbstractSensors, the onlySensorsimplementor, now maps NaN to 0 before memoizing, so the contract holds for every platform and backend. The Javadoc says 0 only, and the tests that tolerated NaN (SensorsTestand both macOS plausibility tests) no longer do.IPConnection.getState()was@Nullableand documented as null for UDP or an unknown state. No implementation passes null (UDP getsTcpState.NONE, unrecognized statesTcpState.UNKNOWN), so this is a documentation and annotation fix; the public constructor normalizes a null argument toUNKNOWN.The only behavior change is FreeBSD's temperature sentinel; it has a CHANGELOG entry.
Testing: full gate on oshi-common, oshi-core and oshi-core-ffm with
-Perror-prone, 0 failures, on macOS. NewAbstractSensorsTestcase covers the NaN mapping. The FreeBSD path itself is untested locally and reaches the getter only through that shared code.Summary by CodeRabbit
0when unavailable, rather thanNaN.UNKNOWN, while UDP connections returnNONE.