Repository navigation
Make the GPU classes' nullability contracts honest - #3621
Conversation
Fourth group of the backlog #3618 left at WARN. Takes oshi-common from 172 warnings to 158 and clears the GPU classes; the reactor drops 568 to 554 with nothing newly surfaced. Two of these describe themselves. LinuxGpuStats caches the NVML device id in a field commented "null means not yet resolved, empty string means unavailable", which is three states in a type that admitted two. findDrmInfo documents "the PCI slot address, or null to use first-match" on both overloads, and is passed as a Function whose input the callers may not know. The rest follow: WindowsGpuStats' two lazily populated caches, MacGpuStats' sampler, which is null when the IOReport subscription could not be created and which the constructor already checks and logs, and DxgiUtil.findMatch with its JNA forwarder. LinuxGraphicsCard and its native-free subclass are here rather than with the peripherals group, because they share findDrmInfo and the DRM lookup function with the GpuStats classes; splitting them would mean deciding one contract in two places.
|
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 (8)
📜 Recent review details⏰ Context from checks skipped due to timeout. (10)
🧰 Additional context used📓 Path-based instructions (4)**/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-common/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/test/java/**/*Test.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/test/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (5)📚 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-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-04-11T05:51:49.185ZApplied to files:
🔇 Additional comments (8)
📝 WalkthroughWalkthroughThe changes add JSpecify ChangesGPU nullability annotations
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR makes GPU nullability contracts accurate without changing runtime behavior, and the supplied verification is green; no actionable merge-blocking risk remains beyond 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 |
Fourth group of the backlog #3618 left at WARN, following #3619 and #3620. Takes
oshi-commonfrom 172 warnings to 158 and clears the GPU classes. The reactor drops 568 to 554 with nothing newly surfaced.No behavior changes.
Two of these describe themselves
LinuxGpuStatscaches the NVML device id in a field carrying this comment:Three states in a type that admitted two.
WindowsGpuStatskeeps the same cache, plus a previous-ticks snapshot that is null until the first sample.findDrmInfodocuments@param pciSlot the PCI slot address ... or null to use first-matchon both overloads, and is handed togetGraphicsCardsFrom*as aFunctionwhose input the callers may genuinely not know —lspcidoes not always report a slot.The rest follow the same pattern:
MacGpuStats.sampler, which is null when the IOReport subscription could not be created — the constructor already checks for that and logs it — andDxgiUtil.findMatchwith its JNA forwarder, whose javadoc already said "ornull".Scope note
LinuxGraphicsCardandLinuxGraphicsCardNFare in this group rather than with the peripherals later on. They sharefindDrmInfoand the DRM lookupFunctionwith the GpuStats classes, so splitting them would mean deciding one contract in two separate reviews — the same fragmentation avoided by grouping these changes by subsystem rather than by operating system.Verification
Full gate green locally on macOS/JDK 25:
./mvnw clean spotless:apply sortpom:sort checkstyle:check install forbiddenapis:check javadoc:javadoc, 1561 tests passing, plus./mvnw -Perror-prone clean install -DskipTestsbuilding successfully across the reactor.Two assertions were added in
DxgiUtilTest, at the two places that dereference the now-nullablefindMatchresult. The tests that assert it returns null are untouched.Summary by CodeRabbit
Bug Fixes
Tests