Repository navigation
AIX: extract more testable parse methods from command readers - #3503
Conversation
Second batch of AIX parse-seam extractions (after #3501), splitting acquisition from parsing so the parsing is unit-testable with synthetic fixtures: - Lspv: parsePpSize(List) + parsePartitions(List, ppSize, majMinMap), splitting the two-command computeLogicalVolumes - Lscfg.parseModelSerial(List, device) - AixCentralProcessor: parseProcessorId(prtconf) -> Quartet, parseCurrentFreq (pmcycles), parseSbits(proc.h), cachesForPowerVersion(version, cores) - AixOperatingSystem.parseServices(lssrc) (no longer mutates the input list to drop the header) - AixFileSystem.parseOpenFileDescriptors(lsof) + parseMaxFileDescriptorsPerProcess Fixtures are grounded in the real lspv -L/-p, lscfg -vl, prtconf, pmcycles -m, proc.h, lssrc -a, lsof -nl, and /etc/security/limits output. As with #3501 the AIX package is still JaCoCo-excluded, so this is testability groundwork; the existing @EnabledOnOs(AIX) live smoke tests are unaffected.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (13)
📝 WalkthroughWalkthroughAIX command execution is separated from parsing for device, processor, filesystem, and service data. New unit tests cover parser outputs, defaults, edge cases, and existing cache behavior. ChangesAIX parser refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes 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 #3503 +/- ##
============================================
- Coverage 76.44% 76.42% -0.03%
Complexity 76 76
============================================
Files 591 591
Lines 21695 21695
Branches 3611 3611
============================================
- Hits 16585 16580 -5
- Misses 3164 3168 +4
- Partials 1946 1947 +1
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
oshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.java (1)
101-108: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPrevent
ArrayIndexOutOfBoundsExceptionon missing device description.If the
devicestring appears at the very end of the line (e.g., there is no trailing description text),s.split(device)will return an array of length 1. Accessing index[1]will then throw anArrayIndexOutOfBoundsException. Adding a length check ensures this fallback safely skips when no description is present.🛡️ Proposed fix
- if (model == null && s.contains(device)) { - String locDesc = s.split(device)[1].trim(); - int idx = locDesc.indexOf(' '); - if (idx > 0) { - model = locDesc.substring(idx).trim(); - } - } + if (model == null && s.contains(device)) { + String[] split = s.split(device); + if (split.length > 1) { + String locDesc = split[1].trim(); + int idx = locDesc.indexOf(' '); + if (idx > 0) { + model = locDesc.substring(idx).trim(); + } + } + }🤖 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/driver/common/unix/aix/Lscfg.java` around lines 101 - 108, Update the fallback logic in Lscfg’s model-parsing block to inspect the result of s.split(device) before accessing element [1]. Only derive locDesc and update model when a second element exists; otherwise safely skip the fallback while preserving the existing description parsing behavior.
🧹 Nitpick comments (1)
oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessor.java (1)
108-121: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider using
substringinstead ofsplitfor prefix extraction.Creating a regular expression and an array just to extract the remainder of a line is slightly less efficient and can throw an
ArrayIndexOutOfBoundsExceptionif the line ends exactly with the marker string. SincestartsWithalready confirms the prefix, usingsubstringis safer and cleaner.♻️ Proposed refactor
for (final String checkLine : prtconf) { if (checkLine.startsWith(nameMarker)) { - cpuName = checkLine.split(nameMarker)[1].trim(); + cpuName = checkLine.substring(nameMarker.length()).trim(); if (cpuName.startsWith("P")) { cpuVendor = "IBM"; } else if (cpuName.startsWith("I")) { cpuVendor = "Intel"; } } else if (checkLine.startsWith(familyMarker)) { - cpuFamily = checkLine.split(familyMarker)[1].trim(); + cpuFamily = checkLine.substring(familyMarker.length()).trim(); } else if (checkLine.startsWith(bitnessMarker)) { - cpu64bit = checkLine.split(bitnessMarker)[1].contains("64"); + cpu64bit = checkLine.substring(bitnessMarker.length()).contains("64"); } }🤖 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/hardware/common/platform/unix/aix/AixCentralProcessor.java` around lines 108 - 121, Replace the split-based prefix extraction in the prtconf loop with substring operations after the existing startsWith checks. Update the nameMarker and familyMarker branches in AixCentralProcessor so they safely trim the text following each marker while preserving the current vendor and family assignment behavior.
🤖 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/unix/aix/AixCentralProcessor.java`:
- Around line 147-148: Update the cache lookup in AixCentralProcessor to pass
the POWER version parsed from prtconf’s Processor Version field to
cachesForPowerVersion instead of parsing uname -n; reuse the existing parsed
version value and leave the cores argument unchanged.
---
Outside diff comments:
In `@oshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.java`:
- Around line 101-108: Update the fallback logic in Lscfg’s model-parsing block
to inspect the result of s.split(device) before accessing element [1]. Only
derive locDesc and update model when a second element exists; otherwise safely
skip the fallback while preserving the existing description parsing behavior.
---
Nitpick comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessor.java`:
- Around line 108-121: Replace the split-based prefix extraction in the prtconf
loop with substring operations after the existing startsWith checks. Update the
nameMarker and familyMarker branches in AixCentralProcessor so they safely trim
the text following each marker while preserving the current vendor and family
assignment behavior.
🪄 Autofix (Beta)
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
Run ID: d4bd7c26-97fd-4a98-9a09-09eca71f2593
📒 Files selected for processing (10)
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/hardware/common/platform/unix/aix/AixCentralProcessor.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.javaoshi-common/src/test/java/oshi/driver/common/unix/aix/LscfgTest.javaoshi-common/src/test/java/oshi/driver/common/unix/aix/LspvTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessorTest.javaoshi-common/src/test/java/oshi/software/common/os/unix/aix/AixFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/os/unix/aix/AixOperatingSystemTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (14)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 21, ubuntu-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 26, macos-latest
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.
Applied to files:
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.javaoshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.javaoshi-common/src/main/java/oshi/driver/common/unix/aix/Lspv.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessor.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.
Applied to files:
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.javaoshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.javaoshi-common/src/main/java/oshi/driver/common/unix/aix/Lspv.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessor.java
📚 Learning: 2026-04-12T19:34:56.879Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:34:56.879Z
Learning: In OSHI’s Java platform implementations, `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` follow the same convention as Windows `PROCESSOR_RELATIONSHIP.EfficiencyClass`: a *higher* numeric efficiency class value represents *greater performance* and *less efficiency* (typically P-cores higher than E-cores). When reviewing, do not treat cases where P-cores are assigned higher efficiency/class values as a bug—this is intentional cross-platform consistency.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessor.java
🔇 Additional comments (3)
oshi-common/src/main/java/oshi/driver/common/unix/aix/Lspv.java (1)
55-68: LGTM!Also applies to: 85-108, 140-140
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java (1)
175-189: LGTM!Also applies to: 204-216
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java (1)
179-195: LGTM!Also applies to: 197-227
Address CodeRabbit review on the AIX parse extraction: - AixCentralProcessor.parseProcessorId: replace split(marker)[1] with substring(marker.length()) after the existing startsWith checks, so a bare marker line with no value (e.g. "Processor Type:") no longer throws ArrayIndexOutOfBounds. - Lscfg.parseModelSerial: check the split length before indexing [1], so a line ending in the device name (which splits to a single element) skips the description fallback instead of throwing. Both paths are covered by new fixture tests. Behavior is otherwise unchanged.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.java (1)
103-110: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
substringoversplitfor literal string extraction.Since
deviceis a literal string rather than a regular expression, usingsplitinside a loop incurs unnecessary regex compilation and array allocation. You can achieve the exact same behavior safely and more efficiently by usingindexOfandsubstring.♻️ Proposed refactor
- String[] locDescSplit = s.split(device); - // A device at the very end of the line splits to a single element; skip the fallback then - if (locDescSplit.length > 1) { - String locDesc = locDescSplit[1].trim(); + int startIdx = s.indexOf(device) + device.length(); + // Skip fallback if the device name is at the very end of the line + if (startIdx < s.length()) { + String locDesc = s.substring(startIdx).trim(); int idx = locDesc.indexOf(' '); if (idx > 0) { model = locDesc.substring(idx).trim(); }🤖 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/driver/common/unix/aix/Lscfg.java` around lines 103 - 110, Update the parsing logic in Lscfg’s device-location extraction to replace s.split(device) with indexOf and substring using the literal device delimiter. Preserve the existing behavior for devices at the end of the line and continue deriving model from the trimmed text after the delimiter.
🤖 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/main/java/oshi/driver/common/unix/aix/Lscfg.java`:
- Around line 103-110: Update the parsing logic in Lscfg’s device-location
extraction to replace s.split(device) with indexOf and substring using the
literal device delimiter. Preserve the existing behavior for devices at the end
of the line and continue deriving model from the trimmed text after the
delimiter.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a46db66d-af92-4b89-be49-a945141a8a61
📒 Files selected for processing (4)
oshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessor.javaoshi-common/src/test/java/oshi/driver/common/unix/aix/LscfgTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessorTest.java
🚧 Files skipped from review as they are similar to previous changes (3)
- oshi-common/src/test/java/oshi/driver/common/unix/aix/LscfgTest.java
- oshi-common/src/test/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessorTest.java
- oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixCentralProcessor.java
📜 Review details
⏰ Context from checks skipped due to timeout. (12)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 26, macos-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.
Applied to files:
oshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.
Applied to files:
oshi-common/src/main/java/oshi/driver/common/unix/aix/Lscfg.java
Follow-up to the earlier split-length guard: use indexOf/substring with the literal device name in Lscfg.parseModelSerial. split(device) treats the device as a regex and needs a length guard for a trailing-token line; indexOf/substring is clearer and handles the end-of-line case directly (empty remainder -> no model). Behavior is unchanged; covered by the existing fixture tests.
…sion (#3504) * Fix AIX processor-cache detection reading the hostname as the POWER version getCachesForModel selected the cache topology from getFirstIntValue(uname -n) -- but uname -n is the network hostname, so on a POWER8 box named e.g. "gcc119" it parsed 119, matched no switch case, and returned an empty cache list. Read the POWER generation from prtconf's "Processor Version" line instead (e.g. PV_8_Compat -> 8), via a new testable parsePowerVersion(prtconf) seam. Verified against real prtconf/uname output from an IBM,8284-22A (POWER8) cfarm host. CHANGELOG entry to be added when the PR is opened (after #3503 lands). * Add CHANGELOG entry for #3504 (AIX cache detection fix)
Summary
Second AIX batch in the parse-seam testability effort (after AIX #3501; and Linux #3494, FreeBSD #3495, NetBSD/OpenBSD #3496, Solaris #3497/#3498, FileSystem #3499, disk drivers #3500). Each acquire-and-parse method keeps its acquisition and delegates to a package-private/
staticparse method taking the already-read input, so the parsing is unit-testable with synthetic fixtures instead of only on a live AIX host:Lspv.parsePpSize(List)+Lspv.parsePartitions(List, ppSize, majMinMap)— splitting the two-commandcomputeLogicalVolumesLscfg.parseModelSerial(List, device)AixCentralProcessor:parseProcessorId(prtconf)→Quartet,parseCurrentFreq(pmcycles, count),parseSbits(proc.h),cachesForPowerVersion(version, cores)AixOperatingSystem.parseServices(lssrc)(no longer mutates its input to drop the header)AixFileSystem.parseOpenFileDescriptors(lsof)+parseMaxFileDescriptorsPerProcess(limits)Fixtures are grounded in the real
lspv -L/-p,lscfg -vl,prtconf,pmcycles -m,/usr/include/sys/proc.h,lssrc -a,lsof -nl, and/etc/security/limitsoutput. New parse tests run on every platform; the existing AIX-only@EnabledOnOs(OS.AIX)live smoke tests are unaffected.Note on coverage
As with #3501, the AIX package is still JaCoCo-excluded (
**/unix/aix/**), so this lands as testability / regression-safety groundwork rather than an immediate coverage bump — un-excluding AIX is a separate follow-up.Testing
oshi-commonfull gate green: spotless, checkstyle, install + forbiddenapis, javadoc; clean full-reactorinstallgreen.No CHANGELOG entry — test/coverage refactor with no user-observable behavior change.
Summary by CodeRabbit