Repository navigation
Replace two duplicated parse helpers with their ParseUtil equivalents - #3580
Conversation
Two private helpers reimplemented logic that already existed elsewhere. LinuxVirtualMemory.parseMeminfo multiplied a /proc/meminfo value by 1024 when its unit column was "kB". LinuxGlobalMemory, parsing the same file, already used ParseUtil.parseDecimalMemorySizeToBinary for exactly this. Split the line with a limit of 2 to keep the value and unit together, as LinuxGlobalMemory does, and delegate. Verified equivalent across the realistic inputs, including a missing unit, tabs, non-numeric values, a malformed single-field line, and a value that overflows a long. The two differ only on a hypothetical "MB" unit, which the kernel never emits for these fields, and where the new behavior is the more correct of the two. SessionWtsData and SessionWtsDataFFM each carried a byte-identical convertBytesToInts converting the WTS_CLIENT_ADDRESS Address member to the int[4] that ParseUtil.parseUtAddrV6toIP consumes. Hoist it to ParseUtil.parseIPv6BytesToIntArray, next to its only consumer, and add a length guard so a short array throws IllegalArgumentException rather than IndexOutOfBoundsException from Arrays.copyOfRange. Both twins now share the conversion instead of maintaining separate copies. No user-visible behavior change, so no CHANGELOG entry.
|
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 (5)
📜 Recent review details⏰ Context from checks skipped due to timeout. (8)
🧰 Additional context used📓 Path-based instructions (9)**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/test/java/**/*Test.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*Test.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{java,xml,properties,md}📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core-ffm/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-common/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
{oshi-common,oshi-core}/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (5)📚 Learning: 2026-08-03T00:46:14.953ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
📚 Learning: 2026-07-30T00:35:22.638ZApplied to files:
📚 Learning: 2026-08-02T23:56:23.866ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
🔇 Additional comments (5)
📝 WalkthroughWalkthroughThe change adds shared IPv6 byte conversion, updates Windows session parsers to use it, and simplifies Linux ChangesIPv6 parsing centralization
Linux memory parsing
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 #3580 +/- ##
============================================
- Coverage 80.03% 79.98% -0.06%
+ Complexity 3868 3867 -1
============================================
Files 709 709
Lines 24205 24206 +1
Branches 4048 4047 -1
============================================
- Hits 19373 19360 -13
- Misses 2689 2694 +5
- Partials 2143 2152 +9
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 private helpers reimplemented logic that already existed elsewhere. Follow-up to #3579, continuing the sweep for private helpers that
ParseUtilalready covers.LinuxVirtualMemory.parseMeminfo→ParseUtil.parseDecimalMemorySizeToBinaryparseMeminfomultiplied a/proc/meminfovalue by 1024 when its unit column was"kB".LinuxGlobalMemory, parsing the same file, already usedParseUtil.parseDecimalMemorySizeToBinaryfor exactly this. The two siblings now agree.The split limit had to change from unlimited to 2, matching
LinuxGlobalMemory, so the value and unit reachparseDecimalMemorySizeToBinaryas one string. I verified equivalence across the realistic inputs rather than by eye:SwapTotal: 2000000 kBSwapTotal: 2000000(no unit)SwapTotal:\t2000000\tkB(tabs)SwapTotal: garbage kBSwapTotal:(malformed, single field)SwapTotal: 9007199254740992 kB(overflows long)SwapTotal: 2000000 MBThe last row is the only divergence. The kernel never emits
MBfor these fields — they are alwayskB— and on that hypothetical input the new behavior is the more correct of the two.convertBytesToInts→ParseUtil.parseIPv6BytesToIntArraySessionWtsDataandSessionWtsDataFFMeach carried a byte-identical copy converting theWTS_CLIENT_ADDRESSAddressmember to theint[4]thatParseUtil.parseUtAddrV6toIPconsumes — the JNA copy's javadoc already pointed atParseUtil#parseUtAddrV6toIPas its only consumer, so that is where it now lives. Both twins share the conversion instead of maintaining separate copies.One small hardening while hoisting: a length guard so a short array throws
IllegalArgumentExceptionwith a clear message rather thanIndexOutOfBoundsExceptionfromArrays.copyOfRange, matching how the adjacentparseUtAddrV6toIPrejects a wrong-length input.No user-visible behavior change, so no CHANGELOG entry.
Verification
Full gate green:
clean spotless:apply sortpom:sort checkstyle:check install forbiddenapis:checkplusjavadoc:javadoc, 0 tests failed across all modules. NewtestParseIPv6BytesToIntArrayconfirmed executing ([OK]in the console-launcher output, not just present in the source). Fork CI green on Windows — which covers theSessionWtsDatapaths I cannot exercise on macOS — and on Linux, which covers the/proc/meminfochange.Summary by CodeRabbit