Repository navigation
Fix all Error Prone StringSplitter findings, fix silent -Xmaxwarns truncation - #3597
Conversation
…rest javac defaults -Xmaxwarns to 100 per module; Error Prone's findings are javac warnings, so oshi-common (117+ findings) was silently truncating everything past the 100th with no indication anything was dropped. Every category count from the prior triage was an undercount because of this - StringSplitter alone was 142 findings, not the 55 originally visible. Set -Xmaxwarns to a large value in the error-prone profile so the full picture is always visible going forward. Fixes all 142 StringSplitter findings. Most are String.split(regex) with no explicit limit, which silently drops trailing empty strings - passing -1 preserves them, satisfying the check. Reviewed each site individually rather than applying -1 uniformly: - Sites indexing the first element ([0]) or the element right after a marker ([1]) are unaffected, or in the marker case actively benefit: a marker as the very last text on a line no longer throws ArrayIndexOutOfBoundsException, it now returns an empty string. - Sites indexing from the end (length-1, length==N checks) only get -1 where the input was already trimmed first or had an explicit isEmpty() guard, eliminating the trailing-whitespace case -1 would otherwise affect. Three sites (LinuxOSProcess.parseAffinityMask, AixFileSystem's inode parsing, SolarisOSProcess's affinity parsing, and the shared ParseUtil.parseLastString) needed an explicit .trim() added alongside -1, since blindly adding -1 there would have silently turned a correctly-parsed value into a wrong default on trailing whitespace - exactly the regression risk with treating -1 as a universal fix. - A handful of "== 2" exact-length checks (AbstractGlobalMemory, MacGlobalMemory, ProcUtil.parseStatistics) now capture a key with an explicit empty value instead of silently dropping the line, matching existing precedent elsewhere in the codebase for this shape. No CHANGELOG entry for the lint-motivated changes; the AIOOBE-prevention and ParseUtil.parseLastString hardening are edge-case fixes on malformed native output, not something normal use should encounter.
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (9)
🧰 Additional context used📓 Path-based instructions (5)oshi-common/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{java,md}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{java,xml}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (6)📚 Learning: 2026-08-05T23:44:09.936ZApplied to files:
📚 Learning: 2026-08-05T23:44:09.936ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied 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:
🔇 Additional comments (1)
📝 WalkthroughWalkthroughThe change updates split operations across OS-specific drivers, hardware and software parsers, shared utilities, native bindings, tests, and build configuration. Most splits now preserve trailing empty fields. Some metadata parsers split only at the first delimiter. ChangesSplit preservation
Estimated code review effort: 3 (Moderate) | ~20 minutes 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❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3597 +/- ##
============================================
- Coverage 79.92% 79.78% -0.15%
- Complexity 3870 4214 +344
============================================
Files 710 710
Lines 24242 24249 +7
Branches 4052 4056 +4
============================================
- Hits 19376 19347 -29
- Misses 2711 2742 +31
- Partials 2155 2160 +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:
|
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
oshi-common/src/main/java/oshi/util/driver/linux/proc/CpuStat.java (1)
51-59: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRework length checks after preserving trailing fields.
split(..., -1)preserves trailing empty tokens. InparseSystemCpuLoadTicksandparseProcessorCpuLoadTicks,"cpu 1 2 "passes the current guard although the requiredIDLEvalue is missing. Validate the required numeric token and allow an optional trailing empty token.In
parseContextSwitches,"ctxt 987654 "has three tokens and fails== 2. Validate token 1 and ignore trailing empty tokens.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@oshi-common/src/main/java/oshi/util/driver/linux/proc/CpuStat.java` around lines 51 - 59, Update parseSystemCpuLoadTicks and parseProcessorCpuLoadTicks to validate that the token at TickType.IDLE is a valid required numeric value, while permitting one trailing empty token from split(..., -1). Update parseContextSwitches to validate token 1 and ignore trailing empty tokens instead of requiring exactly two tokens.oshi-common/src/main/java/oshi/util/ProcUtil.java (1)
132-140: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winTrim statistics lines before splitting.
When a statistics line ends with whitespace,
separator.split(line, -1)adds an empty field, so theparts.length == 2check discards the record. Trimlinebefore splitting and add a trailing-whitespace test.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@oshi-common/src/main/java/oshi/util/ProcUtil.java` around lines 132 - 140, Update the statistics-line parsing around separator.split in ProcUtil to trim trailing whitespace from line before splitting, and add a test covering a line with trailing whitespace to ensure it still produces exactly two fields and is stored in result.
🧹 Nitpick comments (1)
oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java (1)
256-256: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUpdate the token-count comment for
split("\\D+", -1).A nonnumeric final limit now produces a trailing empty token. It does not produce fewer tokens. Update the comment so it matches the implementation and keeps the
parseLongOrDefaultfallback clear.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java` at line 256, Update the comment adjacent to the split call in SolarisOSProcess so it accurately states that a nonnumeric final limit creates a trailing empty token rather than reducing the token count, and clarify how this supports the parseLongOrDefault fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java`:
- Line 134: Update the copyright parsing in LinuxFirmware to trim trailing
whitespace from vcgencmd.get(1) before splitting, ensuring the final token
contains the manufacturer instead of an empty value. Add a trailing-whitespace
fixture in LinuxFirmwareTest covering this case.
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java`:
- Around line 96-97: Update both key/value parsers in MacGlobalMemory to use a
bounded split with a maximum of two parts when parsing system_profiler lines.
Preserve values containing additional colons by splitting only at the first
colon, and keep the existing split.length == 2 handling.
In
`@oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 291-294: Update the provider-path parsing in
WindowsFileSystemFFM.java lines 291-294 and WindowsFileSystemJNA.java lines
239-242 to select the last non-empty component of volume, including when
PROVIDERNAME ends with a backslash. Preserve the existing description update
behavior while ignoring trailing empty split tokens in both implementations.
---
Outside diff comments:
In `@oshi-common/src/main/java/oshi/util/driver/linux/proc/CpuStat.java`:
- Around line 51-59: Update parseSystemCpuLoadTicks and
parseProcessorCpuLoadTicks to validate that the token at TickType.IDLE is a
valid required numeric value, while permitting one trailing empty token from
split(..., -1). Update parseContextSwitches to validate token 1 and ignore
trailing empty tokens instead of requiring exactly two tokens.
In `@oshi-common/src/main/java/oshi/util/ProcUtil.java`:
- Around line 132-140: Update the statistics-line parsing around separator.split
in ProcUtil to trim trailing whitespace from line before splitting, and add a
test covering a line with trailing whitespace to ensure it still produces
exactly two fields and is stored in result.
---
Nitpick comments:
In
`@oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java`:
- Line 256: Update the comment adjacent to the split call in SolarisOSProcess so
it accurately states that a nonnumeric final limit creates a trailing empty
token rather than reducing the token count, and clarify how this supports the
parseLongOrDefault fallback.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c912e86-0451-42e6-abd9-6f9185bc1ece
📒 Files selected for processing (93)
oshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.javaoshi-common/src/main/java/oshi/driver/common/unix/aix/Lspv.javaoshi-common/src/main/java/oshi/driver/common/unix/bsd/Systat.javaoshi-common/src/main/java/oshi/driver/common/unix/bsd/disk/Disklabel.javaoshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.javaoshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomPartList.javaoshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Iostat.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/CupsPrinter.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdComputerSystem.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdPowerSource.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdVirtualMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdHWDiskStore.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsLogicalVolumeGroup.javaoshi-common/src/main/java/oshi/software/common/AbstractNetworkParams.javaoshi-common/src/main/java/oshi/software/common/os/linux/LinuxCgroupInfo.javaoshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/linux/LinuxInternetProtocolStats.javaoshi-common/src/main/java/oshi/software/common/os/linux/LinuxNetworkParams.javaoshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/linux/nativefree/LinuxOperatingSystemNF.javaoshi-common/src/main/java/oshi/software/common/os/mac/MacNetworkParams.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixNetworkParams.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/dragonflybsd/DragonFlyBsdOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOperatingSystem.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsNetworkParams.javaoshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSThread.javaoshi-common/src/main/java/oshi/util/EdidUtil.javaoshi-common/src/main/java/oshi/util/FileSystemUtil.javaoshi-common/src/main/java/oshi/util/ParseUtil.javaoshi-common/src/main/java/oshi/util/PrivilegedUtil.javaoshi-common/src/main/java/oshi/util/ProcUtil.javaoshi-common/src/main/java/oshi/util/UserGroupInfo.javaoshi-common/src/main/java/oshi/util/common/platform/mac/SmcKeyIndex.javaoshi-common/src/main/java/oshi/util/common/platform/unix/dragonflybsd/ProcstatUtil.javaoshi-common/src/main/java/oshi/util/common/platform/unix/netbsd/FstatUtil.javaoshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.javaoshi-common/src/main/java/oshi/util/driver/linux/Lshw.javaoshi-common/src/main/java/oshi/util/driver/linux/proc/CpuInfo.javaoshi-common/src/main/java/oshi/util/driver/linux/proc/CpuStat.javaoshi-common/src/main/java/oshi/util/driver/linux/proc/DiskStats.javaoshi-common/src/main/java/oshi/util/driver/linux/proc/ProcessStat.javaoshi-common/src/main/java/oshi/util/driver/unix/Lpstat.javaoshi-common/src/main/java/oshi/util/driver/unix/ProcLimits.javaoshi-common/src/main/java/oshi/util/driver/unix/Xwininfo.javaoshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.javaoshi-core-ffm/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/mac/MacOSProcessFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/mac/MacOperatingSystemFFM.javaoshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.javaoshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.javaoshi-core/src/main/java/oshi/software/os/mac/MacOperatingSystemJNA.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.javapom.xml
Addresses CodeRabbit findings on the StringSplitter fix, all confirmed against current code before changing anything: - LinuxFirmware.queryVcGenCmd: trim the copyright line before splitting, so a trailing-whitespace line finds the real manufacturer token instead of falling back to UNKNOWN via the isEmpty() guard. - AbstractGlobalMemory/MacGlobalMemory: bound the key/value split to 2 parts instead of unlimited, so a value containing a colon (e.g. a hex serial number) isn't split further and silently dropped by the length==2 check. - WindowsFileSystemFFM/JNA: search backward for the last non-empty volume-path component instead of only checking the absolute last element, so a trailing backslash in PROVIDERNAME doesn't leave the description unset. - CpuStat: the length<=IDLE.getIndex() guards (both tick-parsing methods) discount a trailing empty token before checking, so a genuinely truncated line (missing real fields) can't have a phantom empty token count as one, which previously caused a partially fabricated tick array instead of the safe all-zero fallback. parseContextSwitches loosened length==2 to >=2 for the same reason, without the fabrication risk since it only reads index 1. - ProcUtil.parseStatistics: trim the line before splitting, so a trailing-whitespace line still produces exactly two fields instead of being silently dropped entirely by the length==2 check. - SolarisOSProcess: corrected a comment that described the wrong mechanism (said "fewer tokens", actually produces a trailing empty token that parseLongOrDefault gracefully defaults on). Given how many of these turned out to be real, did a systematic re-audit of every touched file rather than trusting the original per-site review: grepped for every exact length==N check, every length threshold check paired with an independently-bounded loop (the CpuStat shape), and every length-1 end-index, then verified each against its actual input (trimmed already? guarded already? exception-caught?). Found and fixed the above; confirmed the remainder fall into one of: already trimmed before the split, already guarded, exception-caught with an identical outcome either way, or unrelated to this change (native arrays, byte arrays, untouched pre-existing code with an explicit positive limit already). Added a trailing-whitespace fixture to LinuxFirmwareTest and a new ProcUtilsTest covering the same for parseStatistics.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/util/ProcUtilsTest.java (1)
77-87: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftUse fixture data at the parser boundary.
ProcUtil.parseStatistics(procFile.toString())treats the value as a path and callsFileUtil.readFile, so this test depends on filesystem acquisition.If no fixture-data overload exists, extract the parsing loop into a package-private method that accepts
List<String>. Test that method with the trailing-whitespace line as an in-memory fixture.As per coding guidelines:
**/src/test/java/**/*.javarequires tests to use parsing methods that accept fixture data such asList<String>orString, rather than requiring native calls or file/command acquisition. Based on learnings: the same repository rule applies to these parser tests.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@oshi-common/src/test/java/oshi/util/ProcUtilsTest.java` around lines 77 - 87, Update testParseStatisticsWithTrailingWhitespace to exercise the parser with in-memory fixture data instead of a temporary file and path-based ProcUtil.parseStatistics. If no suitable overload exists, extract the parsing loop into a package-private ProcUtil method accepting List<String>, then pass the trailing-whitespace line directly to that method while preserving the existing assertion.Sources: Coding guidelines, Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@oshi-common/src/test/java/oshi/util/ProcUtilsTest.java`:
- Around line 77-87: Update testParseStatisticsWithTrailingWhitespace to
exercise the parser with in-memory fixture data instead of a temporary file and
path-based ProcUtil.parseStatistics. If no suitable overload exists, extract the
parsing loop into a package-private ProcUtil method accepting List<String>, then
pass the trailing-whitespace line directly to that method while preserving the
existing assertion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 55b3f428-ef03-4ca9-be84-7a11604b8f8b
📒 Files selected for processing (11)
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdPowerSource.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.javaoshi-common/src/main/java/oshi/util/ProcUtil.javaoshi-common/src/main/java/oshi/util/driver/linux/proc/CpuStat.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/ProcUtilsTest.javaoshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
🚧 Files skipped from review as they are similar to previous changes (9)
- oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
- oshi-common/src/main/java/oshi/util/ProcUtil.java
- oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdPowerSource.java
- oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacGlobalMemory.java
- oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java
- oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
- oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
- oshi-common/src/main/java/oshi/util/driver/linux/proc/CpuStat.java
- oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java
📜 Review details
⏰ Context from checks skipped due to timeout. (9)
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle)
- GitHub Check: Error Prone
- GitHub Check: Analyze (java)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.java
📄 CodeRabbit inference engine (AGENTS.md)
**/*.java: Do not use banned numeric parsing APIs such asInteger.parseInt,Long.parseLong,Double.parseDouble, orInteger.decode; use the appropriateoshi.util.ParseUtilmethod.
New classes should declare an appropriate concurrency annotation such as@ThreadSafe,@Immutable,@NotThreadSafe, or@GuardedBy, matching the modeled class where applicable.
Files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/ProcUtilsTest.java
**/*.{java,md}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{java,md}: When changing a JNA or FFM implementation, apply the equivalent behavior change to its counterpart, or document why the implementations intentionally differ; prefer hoisting non-native-specific logic intooshi-common.
Use current-year-only copyright headers for new files (Copyright 2026 The OSHI Project ContributorsandSPDX-License-Identifier: MIT); do not commit generated output,target/, or IDE files.
Files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/ProcUtilsTest.java
**/src/test/java/**/*.java
📄 CodeRabbit inference engine (AGENTS.md)
Write tests against parsing methods that accept fixture data such as
List<String>orString, rather than requiring native calls or file/command acquisition.
Files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/ProcUtilsTest.java
**/src/test/java/**/*Test.java
📄 CodeRabbit inference engine (AGENTS.md)
Tests must assert invariants such as non-null values, types, ordering, and plausible ranges rather than hardware-specific values; zero and empty results are valid, and timing-sensitive live readings should not be compared directly.
Files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/ProcUtilsTest.java
**/*.{java,xml}
📄 CodeRabbit inference engine (AGENTS.md)
Do not add line-range Checkstyle suppressions. Prefer declaration-level
@SuppressWarnings, scoped Checkstyle comments, or file/package suppressions without line ranges; use Sonar@SuppressWarnings("java:Sxxxx")where possible and keep statement-level suppression comments short and justified.
Files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/ProcUtilsTest.java
🧠 Learnings (5)
📚 Learning: 2026-07-30T00:35:25.835Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:25.835Z
Learning: In OSHI, only classes annotated with `PublicAPI` are considered API-breaking when changed. Public classes without `PublicAPI`, including `oshi.hardware.common.platform.unix.BsdFirmware`, are internal implementation details. `BsdFirmware.parseDmesg(List<String>)` is intentionally package-private to support tests in its package.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java
📚 Learning: 2026-08-03T00:46:14.953Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3566
File: oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdNetworkParams.java:18-22
Timestamp: 2026-08-03T00:46:14.953Z
Learning: In the OSHI Java codebase, do not require duplicate Javadoc on public methods annotated with Override when the inherited Javadoc from the parent declaration adequately documents the method. The general public-member Javadoc requirement should not flag these overrides solely because they lack redundant documentation.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/ProcUtilsTest.java
📚 Learning: 2026-08-05T23:44:09.936Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-05T23:44:09.936Z
Learning: Applies to oshi-common/src/main/java/**/*.java : Before adding a parsing helper, check `oshi.util.ParseUtil`; put reusable number, size, frequency, hexadecimal, delimited-field, and date parsing there.
Applied to files:
oshi-common/src/test/java/oshi/util/ProcUtilsTest.java
📚 Learning: 2026-08-05T23:44:09.936Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-05T23:44:09.936Z
Learning: Applies to **/src/test/java/**/*.java : Write tests against parsing methods that accept fixture data such as `List<String>` or `String`, rather than requiring native calls or file/command acquisition.
Applied to files:
oshi-common/src/test/java/oshi/util/ProcUtilsTest.java
📚 Learning: 2026-08-05T23:44:09.936Z
Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-08-05T23:44:09.936Z
Learning: Applies to **/src/main/java/**/*.java : Prefer native calls for system information; on Linux prefer `FileUtil` for `/proc` and `/sys`, while `ExecutingCommand` is acceptable on other platforms when native APIs do not expose the data.
Applied to files:
oshi-common/src/test/java/oshi/util/ProcUtilsTest.java
🔇 Additional comments (2)
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java (1)
79-87: LGTM!oshi-common/src/test/java/oshi/util/ProcUtilsTest.java (1)
13-22: LGTM!
… file Extract the parsing loop into a package-private overload taking List<String> directly, matching the existing "extract parsing from acquisition" pattern used elsewhere (e.g. CpuStat). The trailing- whitespace regression test now exercises that overload with an in-memory fixture instead of writing a real file and going through the file-reading path, which was untested surface irrelevant to what the test is actually checking.
…e 2) (#3615) * Mark oshi.util @NullMarked and normalize null handling (jSpecify Phase 2) Phase 2 of #3593. oshi.util is now @NullMarked, so every type usage in a signature there is non-null unless annotated @nullable. Sixteen methods gained an honest @nullable parameter contract. Each already handled null and was already exercised with null by a test; only the signature was silent about it. GlobalConfig.get(String) is annotated @nullable rather than made to return "", so an absent property stays distinguishable from one set to an empty value, which the two-argument overload cannot express. Adds ParseUtil.getStringValueOrEmpty beside the existing getStringValueOrUnknown and removes Util.isBlankOrUnknown, which had no callers outside its own test. The normalizers replace the spelled-out null check in queryMicroarchitecture that existed only because NullAway cannot see through the Util.isBlank predicate. Two latent bugs surfaced: - ProcUtil.parseNestedStatistics threw ArrayIndexOutOfBoundsException on an empty line. A whitespace-only line splits to length 0 and is skipped, but "" splits to a single empty element, passes the length guard, and is left with nothing by the leading-whitespace shift. The length check now runs after the shift, and the netstat fixture gained an empty line to cover it. The bug is original to the method (058cb8c), not a regression from the #3597 -1 work, which never touched it: StringSplitter flags String.split only, so the Pattern.split surface was outside that sweep. - GlobalConfigTest's asserter matched no branch when the expected default was null, so testGetString asserted nothing at all. It now exercises the single-argument get. NullAway analyses test sources, which is what surfaced the parameter contracts above. HandleTestAssertionLibraries is enabled so assertNotNull narrows a nullable for the rest of a test method; Hamcrest's notNullValue() does not, so the assertions preceding a dereference were converted. No suppressions added. * Import DisplayInfo and DisplayInfoImpl in EdidUtil instead of naming them fully qualified AGENTS.md forbids fully-qualified class names in code and in javadoc links. The signature was the worst of these, since annotating the return type for jSpecify had turned it into oshi.hardware.@nullable DisplayInfo. oshi.util already imports from oshi.hardware in GlobalConfig and SystemInfoHelper, and neither type collides with anything in scope.
Establishes the end state for #3593 across oshi-common, oshi-core and oshi-core-ffm. NullAway runs at WARN until the backlog it reports is drained, following the precedent set for the SLF4J check in #3597; it goes back to ERROR once the count reaches zero. Two mechanisms, aimed at what each can actually reach. A package annotation is the only one every consumer sees: a JDK 8 user has no module system at all, and a JDK 9+ user on the classpath does not resolve module annotations either. So the packages a caller touches are annotated individually -- those holding @publicapi types, and the whole oshi.util tree, which callers do sometimes reach for. Everything below that line is per-OS implementation, abstract bases and drivers, which the project already documents as not meant for outside use; those are covered by @NullMarked on the module declaration, which exists to let us check our own code and needs no per-package upkeep as packages are added. The native mapping packages are opted out with @NullUnmarked. The struct and library bindings under oshi.jna and oshi.ffm.platform describe someone else's memory layout rather than our contracts, and are already exempt from the javadoc rules for the same reason. Their utility packages, oshi.jna.util and oshi.ffm.util, are not opted out. oshi-common and oshi-core compile their sources at release 8, which predates JPMS and therefore excludes module-info.java, leaving the module annotation invisible to NullAway. Under -Perror-prone only, they now compile at release 9 with module-info.java included. The released jars are unchanged, still built at release 8. oshi-core and oshi-core-ffm gain the jspecify dependency and a requires static clause, since oshi-common declares it optional and it is therefore not transitive. -Xmaxerrs joins the -Xmaxwarns that #3597 set. NullAway reports at ERROR once the backlog is drained, and javac caps errors at 100 by default just as silently as warnings: a survey of oshi-common reported exactly 100 findings until this was set, against a real 288. Marking oshi.driver.common.windows.wmi showed WmiResult.getValue declaring a non-null return that every caller in WmiUtil immediately null-checks, so a WMI row without the property was already returning null through a signature that promised otherwise. NetBsdCentralProcessor.parseCpTime likewise null-checks the argument it declared non-null. Both are annotated now. Two tests asserted on a map lookup without checking it was present, and one called main(null).
Summary
Follow-on to #3594/#3595/#3596 (Error Prone groundwork). Requested triage of the WARNING-severity backlog by category, starting with the two the user specifically flagged: javadoc (
MissingSummary, deferred to a follow-on PR) andStringSplitter(this PR).Important correction discovered while gathering baseline numbers:
javacdefaults-Xmaxwarnsto 100 per module. Error Prone's findings are javac warnings, sooshi-common(117+ findings) was silently truncating everything past the 100th with no indication anything was dropped. Every category count from the original triage was an undercount because of this -StringSplitteralone was 142 findings, not the 55 originally visible. Set-Xmaxwarnsto a large value in theerror-proneprofile so the full picture is always visible going forward; this also revealed two previously-invisible categories (EffectivelyPrivate,InvalidInlineTag) and grew others substantially (OperatorPrecedence4→29,EnumOrdinal17→39,MissingSummary33→41).StringSplitter (142/142 fixed)
Most sites are
String.split(regex)with no explicit limit, which silently drops trailing empty strings - passing-1preserves them, satisfying the check. Each site was reviewed individually rather than applying-1uniformly, since-1is not a universally-safe substitute for the implicit0limit when a caller indexes the split result from the end or checks an exact length:[0]) or the element right after a marker ([1]) are unaffected by-1, or in the marker case actively benefit: a marker as the very last text on a line no longer throwsArrayIndexOutOfBoundsException, it now returns an empty string.length-1,length==Nchecks) only get-1where the input was already trimmed first or had an explicitisEmpty()guard, eliminating the trailing-whitespace case-1would otherwise affect.LinuxOSProcess.parseAffinityMask,AixFileSystem's inode parsing,SolarisOSProcess's affinity parsing, and the sharedParseUtil.parseLastString) needed an explicit.trim()added alongside-1, since blindly adding-1there would have silently turned a correctly-parsed value into a wrong default (0) on trailing whitespace - exactly the regression risk with treating-1as a universal fix.== 2exact-length checks (AbstractGlobalMemory,MacGlobalMemory,ProcUtil.parseStatistics) now capture a key with an explicit empty value instead of silently dropping the line, matching existing precedent elsewhere in the codebase for this shape.JNA/FFM twins (
SolarisCentralProcessor,MacOperatingSystem,MacOSProcess,WindowsFileSystem) were fixed identically on both sides.No CHANGELOG entry for the lint-motivated changes; the
ArrayIndexOutOfBoundsException-prevention andParseUtil.parseLastStringhardening are edge-case fixes on malformed native output, not something normal use should encounter.Next steps (not this PR)
MissingSummary,EnumOrdinal,OperatorPrecedence,MixedMutabilityReturnType, etc.) now that the true counts are visible.Test plan
./mvnw clean install -DskipTests -Perror-prone:StringSplittercount 142 → 0, BUILD SUCCESS./mvnw test(whole reactor): 1558 tests, 0 failures./mvnw clean spotless:apply sortpom:sort checkstyle:check install forbiddenapis:check javadoc:javadoc: full gate clean, no reformatting needed beyond spotless's own line-wrapping of a few added-1argumentsSummary by CodeRabbit