Repository navigation
Extract parsing logic from dmidecode/lscpu/vcgencmd commands - #3201
Conversation
📝 WalkthroughWalkthroughThis PR separates command execution from parsing across multiple Linux hardware modules by adding package-static parsing helpers that accept pre-fetched List output; existing no-arg methods now run the OS commands and delegate. Tests were added to validate the parsing helpers with fixtures. Changes
Sequence Diagram(s)(Skipped — changes are refactors adding parsing overloads; flows are localized and do not introduce a new multi-component sequential feature requiring visualization.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
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 |
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 (3)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java (1)
123-140:⚠️ Potential issue | 🟡 MinorGuard manufacturer parsing against empty copyright lines.
In malformed-but-possible output,
vcgencmd.get(1)can be blank andcopyright[copyright.length - 1]can throw. A small guard keeps this parser resilient.💡 Proposed fix
// Second line is copyright String[] copyright = ParseUtil.whitespaces.split(vcgencmd.get(1)); - vcManufacturer = copyright[copyright.length - 1]; + vcManufacturer = copyright.length > 0 ? copyright[copyright.length - 1] : Constants.UNKNOWN;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java` around lines 123 - 140, In queryVcGenCmd(List<String> vcgencmd) the code assumes vcgencmd.get(1) contains tokens and accesses copyright[copyright.length - 1], which can throw on blank/malformed lines; before extracting vcManufacturer in LinuxFirmware.queryVcGenCmd, check for null/blank vcgencmd.get(1) and/or that the ParseUtil.whitespaces.split(...) result has length > 0 and a non-empty last token, and if not set vcManufacturer = Constants.UNKNOWN (or trim and use the last token when present); keep the rest of the method flow unchanged and still return new VcGenCmdStrings(vcReleaseDate, vcManufacturer, vcVersion, "RPi", "Bootloader").oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java (1)
51-60:⚠️ Potential issue | 🟠 MajorReset all per-DIMM fields between
DMI type 17entries.Line 56-60 resets only part of the parser state. If a subsequent memory device omits fields, previous
manufacturer/type/part/serialvalues can bleed into the new record.💡 Proposed fix
bankLabel = Constants.UNKNOWN; locator = ""; capacity = 0L; speed = 0L; + manufacturer = Constants.UNKNOWN; + memoryType = Constants.UNKNOWN; + partNumber = Constants.UNKNOWN; + serialNumber = Constants.UNKNOWN; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java` around lines 51 - 60, The parser only resets locator/capacity/speed on closing a DMI type 17 entry, so manufacturer/memoryType/partNumber/serialNumber can leak into the next record; update the block handling "if (bank++ > 0)" in AbstractGlobalMemory to reset all per‑DIMM state variables (bankLabel, locator, capacity, speed, manufacturer, memoryType, partNumber, serialNumber) after adding the PhysicalMemory to pmList (use Constants.UNKNOWN or empty strings/zeros as appropriate) so each new DMI entry starts with a clean state.oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java (1)
125-143:⚠️ Potential issue | 🟠 MajorHandle BIOS revision marker case-insensitively.
queryBiosNameRev(List<String>)currently matches onlyBios Revision:(Line 130). Real dmidecode output commonly usesBIOS Revision:(all caps), which causes missed revisions.💡 Proposed fix
+import java.util.Locale; import java.util.List; @@ - final String revMarker = "Bios Revision:"; + final String revMarker = "bios revision:"; @@ - if (checkLine.contains(revMarker)) { - revision = checkLine.split(revMarker)[1].trim(); + String lower = checkLine.toLowerCase(Locale.ROOT); + if (lower.contains(revMarker)) { + revision = checkLine.substring(lower.indexOf(revMarker) + revMarker.length()).trim(); // SMBIOS should be first line so if we're here we are done iterating break; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java` around lines 125 - 143, The revision lookup in queryBiosNameRev currently only matches the exact case "Bios Revision:" so lines like "BIOS Revision:" are missed; update the check that uses revMarker to perform a case-insensitive match (for example by comparing checkLine.toLowerCase().contains(revMarker.toLowerCase()) or using a case-insensitive regex/regionMatches) and extract the revision from the matching segment in a case-insensitive-safe way (e.g., locate the index of the marker using the same lowercased search and substring from the original line), then trim and assign to revision and break as before; keep biosMarker handling unchanged.
🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java (1)
70-80: Consider adding a regression test for missing field carry-over.A useful extra case: two populated DIMMs where the second omits
Manufacturer/Part Number, asserting those fields stayunknowninstead of inheriting DIMM1 values.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java` around lines 70 - 80, Add a regression unit test (similar to testParsePhysicalMemorySingleDimm) that calls AbstractGlobalMemory.getPhysicalMemory with two DIMM blocks where the second block omits "Manufacturer" and "Part Number"; assert the returned List<PhysicalMemory> has size 2 and that for the second PhysicalMemory the manufacturer and partNumber fields are "unknown" (or whatever sentinel your PhysicalMemory uses) rather than inheriting values from the first DIMM, and also assert capacities/bank labels are parsed correctly; this ensures getPhysicalMemory does not carry over missing fields between entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java`:
- Around line 31-36: Update the test fixtures to include a capitalization
variant for the BIOS revision field so the parser handles "BIOS Revision:" as
well as "Bios Revision:". Add a line with "\tBIOS Revision: 2.5" (or matching
value) to the BIOS_OUTPUT List used in DmidecodeTest and do the same for the
other fixture list referenced around lines 57-77 so both test cases include the
uppercase "BIOS Revision" variant; ensure you modify the constants (BIOS_OUTPUT
and the other fixture list) rather than test logic.
---
Outside diff comments:
In `@oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java`:
- Around line 51-60: The parser only resets locator/capacity/speed on closing a
DMI type 17 entry, so manufacturer/memoryType/partNumber/serialNumber can leak
into the next record; update the block handling "if (bank++ > 0)" in
AbstractGlobalMemory to reset all per‑DIMM state variables (bankLabel, locator,
capacity, speed, manufacturer, memoryType, partNumber, serialNumber) after
adding the PhysicalMemory to pmList (use Constants.UNKNOWN or empty
strings/zeros as appropriate) so each new DMI entry starts with a clean state.
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java`:
- Around line 123-140: In queryVcGenCmd(List<String> vcgencmd) the code assumes
vcgencmd.get(1) contains tokens and accesses copyright[copyright.length - 1],
which can throw on blank/malformed lines; before extracting vcManufacturer in
LinuxFirmware.queryVcGenCmd, check for null/blank vcgencmd.get(1) and/or that
the ParseUtil.whitespaces.split(...) result has length > 0 and a non-empty last
token, and if not set vcManufacturer = Constants.UNKNOWN (or trim and use the
last token when present); keep the rest of the method flow unchanged and still
return new VcGenCmdStrings(vcReleaseDate, vcManufacturer, vcVersion, "RPi",
"Bootloader").
In `@oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java`:
- Around line 125-143: The revision lookup in queryBiosNameRev currently only
matches the exact case "Bios Revision:" so lines like "BIOS Revision:" are
missed; update the check that uses revMarker to perform a case-insensitive match
(for example by comparing
checkLine.toLowerCase().contains(revMarker.toLowerCase()) or using a
case-insensitive regex/regionMatches) and extract the revision from the matching
segment in a case-insensitive-safe way (e.g., locate the index of the marker
using the same lowercased search and substring from the original line), then
trim and assign to revision and break as before; keep biosMarker handling
unchanged.
---
Nitpick comments:
In
`@oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java`:
- Around line 70-80: Add a regression unit test (similar to
testParsePhysicalMemorySingleDimm) that calls
AbstractGlobalMemory.getPhysicalMemory with two DIMM blocks where the second
block omits "Manufacturer" and "Part Number"; assert the returned
List<PhysicalMemory> has size 2 and that for the second PhysicalMemory the
manufacturer and partNumber fields are "unknown" (or whatever sentinel your
PhysicalMemory uses) rather than inheriting values from the first DIMM, and also
assert capacities/bank labels are parsed correctly; this ensures
getPhysicalMemory does not carry over missing fields between entries.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 28361f7d-22cd-4b83-886b-a4218d6218ba
📒 Files selected for processing (8)
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.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/util/driver/linux/Dmidecode.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2026-04-14T23:28:18.252Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3160
File: oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxSensorsTest.java:34-40
Timestamp: 2026-04-14T23:28:18.252Z
Learning: In oshi/oshi, `vcgencmd` (used in `LinuxSensors.queryCpuTemperatureFromVcGenCmd()` and related methods) is a Raspberry Pi-specific binary. It will never be present on standard x86/amd64 CI runners or developer machines. Tests that pass `isPi=true` to `LinuxSensors` and assert 0/empty returns are deterministic in practice; do not flag them as potentially flaky due to `vcgencmd` availability.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
📚 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/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.javaoshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.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/linux/LinuxCentralProcessor.java
🔇 Additional comments (3)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java (1)
316-317: Nice extraction for deterministic parser tests.Delegating command execution to
List<String>parsing overloads here keeps runtime behavior intact while making these paths testable with fixtures. Clean change.Also applies to: 325-342, 345-346, 354-407
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java (1)
46-95: Good fixture coverage for the new parsing helpers.These tests hit the primary success and fallback branches (
empty, comments-only, andways: null) and directly support the refactor goal.oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java (1)
25-74: Strong fixture-based coverage forqueryVcGenCmd(List<String>).These cases validate the intended fallbacks (
null/unknown) and expected Raspberry Pi parsing outputs well.
2d54f75 to
be45eca
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java (1)
60-64: Consider asserting all fields in the “too few lines” case.At the moment this test checks only
releaseDate. Since the parser returns an all-nullVcGenCmdStringsfor short input, asserting manufacturer/version/name/description too would make this edge-case contract explicit.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java` around lines 60 - 64, Update the test method testQueryVcGenCmdTooFewLines in LinuxFirmwareTest to assert that all fields of the returned VcGenCmdStrings are null for short input: in addition to assertThat(result.getReleaseDate(), is(nullValue())), add assertions for result.getManufacturer(), result.getVersion(), result.getName(), and result.getDescription() to be null (use the same assertThat(..., is(nullValue())) style) so the edge-case contract of LinuxFirmware.queryVcGenCmd is explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java`:
- Around line 60-64: Update the test method testQueryVcGenCmdTooFewLines in
LinuxFirmwareTest to assert that all fields of the returned VcGenCmdStrings are
null for short input: in addition to assertThat(result.getReleaseDate(),
is(nullValue())), add assertions for result.getManufacturer(),
result.getVersion(), result.getName(), and result.getDescription() to be null
(use the same assertThat(..., is(nullValue())) style) so the edge-case contract
of LinuxFirmware.queryVcGenCmd is explicit.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a1ab43b8-9172-4ad8-a0f8-10b35def5dbd
📒 Files selected for processing (8)
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.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/util/driver/linux/Dmidecode.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
🚧 Files skipped from review as they are similar to previous changes (4)
- oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java
- oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java
- oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java
- oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java
📚 Learning: 2026-04-14T23:28:18.252Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3160
File: oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxSensorsTest.java:34-40
Timestamp: 2026-04-14T23:28:18.252Z
Learning: In oshi/oshi, `vcgencmd` (used in `LinuxSensors.queryCpuTemperatureFromVcGenCmd()` and related methods) is a Raspberry Pi-specific binary. It will never be present on standard x86/amd64 CI runners or developer machines. Tests that pass `isPi=true` to `LinuxSensors` and assert 0/empty returns are deterministic in practice; do not flag them as potentially flaky due to `vcgencmd` availability.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 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/hardware/common/platform/linux/LinuxCentralProcessor.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/linux/LinuxCentralProcessor.java
🔇 Additional comments (8)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java (2)
324-335: Nice extraction for NUMA parsing testability.Good split between command execution and parsing here. Keeping the no-arg entrypoint while exposing a
List<String>parser makes this path deterministic and easy to unit test without changing external behavior.
353-364: Cache parsing delegation looks clean and consistent.This mirrors the NUMA refactor well: command invocation stays centralized, and the parser overload is package-private for fixture-based tests. Solid maintainability improvement with no API surface change.
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java (3)
21-48: Great fixture-driven coverage for the happy-path parser behavior.Nice split of assertions across date/manufacturer/version/name/description with stable fixture input; this directly validates the new parsing seam without shelling out.
Based on learnings,
vcgencmdis Raspberry Pi-specific, so fixture-based tests like these are the right deterministic approach for CI.
50-58: Good defensive test for empty output.Verifying all fields as
nullhere is a solid guardrail for the parser’s fallback contract.
66-73: Nice edge-case validation for invalid date parsing.This test confirms the date fallback while still asserting manufacturer/version extraction continues correctly.
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java (2)
35-40: Please add an uppercase BIOS revision fixture variant (carry-over).Line 39 still only covers
Bios Revision:casing. Adding aBIOS Revision:fixture case would keep this parser path protected against capitalization variance.Also applies to: 75-81
42-74: Nice extraction-focused test coverage.Good split between deterministic fixture tests and Linux-only live smoke checks; this matches the parsing-extraction objective and keeps runtime fragility low.
Also applies to: 83-102
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java (1)
53-110: Solid fixture-based parser tests.This is a clean, deterministic suite for
getPhysicalMemory(List<String>)with good coverage of populated, empty, and minimal-input paths.
a20b562 to
53ecfb8
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java (1)
112-131: Cover the serial number reset too.This regression test already checks manufacturer and part number, but it leaves the new
serialNumberreset path unasserted. Adding the second DIMM’s serial number would make the state-leak guard complete.♻️ Proposed test expansion
// Second DIMM should have defaults, not Samsung/M393... assertThat(result.get(1).getBankLabel(), is("Bank1/DIMM_B1")); assertThat(result.get(1).getCapacity(), is(4096L * 1024 * 1024)); assertThat(result.get(1).getManufacturer(), is("unknown")); assertThat(result.get(1).getPartNumber(), is("unknown")); + assertThat(result.get(1).getSerialNumber(), is("SN222")); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java` around lines 112 - 131, The test testParsePhysicalMemoryNoStateLeak should also assert the serial number reset to prevent state leak; after calling AbstractGlobalMemory.getPhysicalMemory and the existing assertions for result.get(1), add an assertion that result.get(1).getSerialNumber() equals the default ("unknown") so the second DIMM does not inherit the first DIMM's serial number.oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java (1)
60-64: Tighten the too-short fixture assertion.Right now this test only checks
releaseDate. Adding the other getters here would make the short-input case catch stale-value regressions too.♻️ Proposed test expansion
`@Test` void testQueryVcGenCmdTooFewLines() { VcGenCmdStrings result = LinuxFirmware.queryVcGenCmd(Arrays.asList("Jan 13 2013 16:24:29")); assertThat(result.getReleaseDate(), is(nullValue())); + assertThat(result.getManufacturer(), is(nullValue())); + assertThat(result.getVersion(), is(nullValue())); + assertThat(result.getName(), is(nullValue())); + assertThat(result.getDescription(), is(nullValue())); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java` around lines 60 - 64, The test currently only asserts VcGenCmdStrings.getReleaseDate is null for a too-short input; expand it to assert that all other VcGenCmdStrings accessors also return null (e.g., getManufacturer(), getProductName(), getVersion(), getSerialNumber() or whatever getters exist on VcGenCmdStrings) after calling LinuxFirmware.queryVcGenCmd with the single-line fixture so a stale non-null value on any field will fail the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java`:
- Around line 112-131: The test testParsePhysicalMemoryNoStateLeak should also
assert the serial number reset to prevent state leak; after calling
AbstractGlobalMemory.getPhysicalMemory and the existing assertions for
result.get(1), add an assertion that result.get(1).getSerialNumber() equals the
default ("unknown") so the second DIMM does not inherit the first DIMM's serial
number.
In
`@oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java`:
- Around line 60-64: The test currently only asserts
VcGenCmdStrings.getReleaseDate is null for a too-short input; expand it to
assert that all other VcGenCmdStrings accessors also return null (e.g.,
getManufacturer(), getProductName(), getVersion(), getSerialNumber() or whatever
getters exist on VcGenCmdStrings) after calling LinuxFirmware.queryVcGenCmd with
the single-line fixture so a stale non-null value on any field will fail the
test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 083dba1d-d716-4d58-a32f-7cad0f438ddc
📒 Files selected for processing (8)
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.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/util/driver/linux/Dmidecode.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
✅ Files skipped from review due to trivial changes (1)
- oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
- oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 21, windows-latest
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2026-04-14T23:28:18.252Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3160
File: oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxSensorsTest.java:34-40
Timestamp: 2026-04-14T23:28:18.252Z
Learning: In oshi/oshi, `vcgencmd` (used in `LinuxSensors.queryCpuTemperatureFromVcGenCmd()` and related methods) is a Raspberry Pi-specific binary. It will never be present on standard x86/amd64 CI runners or developer machines. Tests that pass `isPi=true` to `LinuxSensors` and assert 0/empty returns are deterministic in practice; do not flag them as potentially flaky due to `vcgencmd` availability.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 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/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java
🔇 Additional comments (6)
oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java (2)
66-145: Nice split between command execution and parsing.The new list-based overloads keep the privileged
dmidecodecall isolated, and the case-insensitive BIOS revision lookup covers bothBios Revision:andBIOS Revision:without changing the external API.
147-180: KeepingVcGenCmdStringspackage-private is the right scope.This internal DTO is only needed to support the parser tests and the memoized call sites, so exposing it beyond the package would add surface area without benefit.
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java (1)
28-109: Fixture coverage looks solid.The deterministic fixtures exercise the parser path well, including the BIOS revision capitalization variants, and the Linux-gated live checks stay minimal.
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java (2)
72-111: The memoized fallbacks still read cleanly.The supplier chain remains straightforward, and the new list-backed parser keeps the fallback logic readable without changing behavior.
113-180: Good isolation for thevcgencmdparser.Executing the command once and delegating to the list-based parser is exactly the right shape for deterministic tests, and the package-visible DTO keeps the change contained.
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java (1)
75-83: All good! ✓The
parseSpeed()helper already exists inParseUtil(line 195) and is well-tested. The test suite explicitly covers theMT/sformat your code relies on—for example,parseSpeed("1MT/s")correctly returns1_000_000L(representing 1 MHz in Hz), andparseSpeed("1.5 MT/s")returns1_500_000L. The new call at line 82 is a straightforward reuse of an existing, proven utility, so no concerns here.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java`:
- Around line 84-86: In the test method testQueryBiosNameRevLowercaseVariant
update the fixture string so the revision label is actually lowercase: change
the mixed-case entry passed to Dmidecode.queryBiosNameRev (currently "\tBios
Revision: 1.2") to the lowercase form "\tbios revision: 1.2" so the test
exercises the lowercase parsing path in Dmidecode.queryBiosNameRev.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2e957082-3fc6-4da2-a7a2-04b28e827f77
📒 Files selected for processing (8)
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.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/util/driver/linux/Dmidecode.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
🚧 Files skipped from review as they are similar to previous changes (4)
- oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java
- oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java
- oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java
- oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Analyze (java)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (4)
📚 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/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
🔇 Additional comments (10)
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java (3)
28-29: Clean delegation from command execution to parser.Nice refactor here—keeping the public method behavior intact while delegating to the parser overload improves testability without changing API surface.
31-37: Good extraction boundary for deterministic parsing tests.The new overload and Javadoc make the parse contract explicit and keep responsibilities well separated.
60-63: Great fix for per-bank state isolation.Resetting these fields when advancing DIMMs prevents stale metadata from leaking into the next module record.
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java (2)
345-372: Strong deterministic coverage for NUMA parsing helper.Nice addition of fixture-based tests for normal, empty, and comment-only inputs. This directly validates
mapNumaNodesFromLscpu(List<String>)behavior without command execution and matches the PR goal well.
378-416: Cache parsing tests are thorough and validate key edge behavior.Great coverage here: expected L1d/L1i/L2 entries plus explicit verification that
ways: nullmaps to associativity0for L3, and an empty-input case. This is a solid fit for deterministic parsing tests.oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java (4)
74-107: Fallback delegation remains clean and behavior-preserving.Nice refactor here: moving to accessor-based reads keeps the same precedence/fallback behavior while supporting the extracted parser object cleanly.
113-123: Good separation of command execution from parsing.This extraction is exactly what enables fixture-driven tests and keeps runtime behavior unchanged.
137-139: Nice robustness improvement for malformed copyright lines.The empty-token guard avoids returning an empty manufacturer string and correctly normalizes to
Constants.UNKNOWN.
147-180:VcGenCmdStringsis a solid immutable parse result carrier.Package-private visibility plus explicit getters is a good fit for internal parsing tests without exposing public API.
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java (1)
41-81: Nice refactor-aligned test coverage for deterministic parsing + Linux smoke checks.These assertions are clear and targeted, and the split between fixture tests and live no-throw checks is solid.
Also applies to: 91-109
Separate command execution from output parsing in 7 methods across 4 classes, enabling deterministic testing with fixture data: - Dmidecode: querySerialNumber, queryUUID, queryBiosNameRev - AbstractGlobalMemory: getPhysicalMemory (dmidecode --type 17) - LinuxFirmware: queryVcGenCmd (Raspberry Pi firmware) - LinuxCentralProcessor: mapNumaNodesFromLscpu, mapCachesFromLscpu Each method now has a package-private overload accepting List<String>, with the public method delegating after running the command. No public API changes. Added 3 new test classes and enhanced DmidecodeTest with fixture-based tests covering key parsing branches.
53ecfb8 to
22f6e92
Compare
There was a problem hiding this comment.
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/hardware/common/platform/linux/LinuxCentralProcessor.java (1)
341-347:⚠️ Potential issue | 🟡 MinorGuard against malformed
cpu,noderows with missing node values.On Line 344,
pos < line.length()still accepts rows like"3,", which then parse to node0and silently add a bad mapping. Tightening this check avoids false entries.Suggested fix
for (String line : lscpu) { if (!line.startsWith("#")) { int pos = line.indexOf(','); - if (pos > 0 && pos < line.length()) { + if (pos > 0 && pos < line.length() - 1) { numaNodeMap.put(ParseUtil.parseIntOrDefault(line.substring(0, pos), 0), ParseUtil.parseIntOrDefault(line.substring(pos + 1), 0)); } } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java` around lines 341 - 347, In LinuxCentralProcessor inside the for (String line : lscpu) loop, avoid adding mappings for rows that have a trailing comma with no node value (e.g., "3,"); currently the condition pos < line.length() allows that and ParseUtil.parseIntOrDefault silently inserts 0. Change the guard to require a non-empty node substring (e.g., pos >= 0 && pos < line.length() - 1) or explicitly check that line.substring(pos + 1).trim() is not empty before calling ParseUtil.parseIntOrDefault and putting into numaNodeMap so malformed "cpu,node" rows are skipped.
🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java (1)
129-130: UseConstants.UNKNOWNin assertions instead of string literals.Using the shared constant avoids drift if the sentinel value ever changes.
Suggested tweak
import oshi.hardware.PhysicalMemory; import oshi.hardware.VirtualMemory; +import oshi.util.Constants; @@ - assertThat(result.get(1).getManufacturer(), is("unknown")); - assertThat(result.get(1).getPartNumber(), is("unknown")); + assertThat(result.get(1).getManufacturer(), is(Constants.UNKNOWN)); + assertThat(result.get(1).getPartNumber(), is(Constants.UNKNOWN));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java` around lines 129 - 130, Replace the hard-coded "unknown" literals in the assertions with the shared sentinel constant to avoid drift: change the two assertions that call result.get(1).getManufacturer() and result.get(1).getPartNumber() to assert that they equal Constants.UNKNOWN, and add/import Constants if not already available in AbstractGlobalMemoryTest so the test compiles.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java`:
- Around line 341-347: In LinuxCentralProcessor inside the for (String line :
lscpu) loop, avoid adding mappings for rows that have a trailing comma with no
node value (e.g., "3,"); currently the condition pos < line.length() allows that
and ParseUtil.parseIntOrDefault silently inserts 0. Change the guard to require
a non-empty node substring (e.g., pos >= 0 && pos < line.length() - 1) or
explicitly check that line.substring(pos + 1).trim() is not empty before calling
ParseUtil.parseIntOrDefault and putting into numaNodeMap so malformed "cpu,node"
rows are skipped.
---
Nitpick comments:
In
`@oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java`:
- Around line 129-130: Replace the hard-coded "unknown" literals in the
assertions with the shared sentinel constant to avoid drift: change the two
assertions that call result.get(1).getManufacturer() and
result.get(1).getPartNumber() to assert that they equal Constants.UNKNOWN, and
add/import Constants if not already available in AbstractGlobalMemoryTest so the
test compiles.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0c5c4d33-7ab2-4515-bb86-64982911e3bc
📒 Files selected for processing (8)
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.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/util/driver/linux/Dmidecode.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
- oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java
- oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2026-04-14T23:28:18.252Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3160
File: oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxSensorsTest.java:34-40
Timestamp: 2026-04-14T23:28:18.252Z
Learning: In oshi/oshi, `vcgencmd` (used in `LinuxSensors.queryCpuTemperatureFromVcGenCmd()` and related methods) is a Raspberry Pi-specific binary. It will never be present on standard x86/amd64 CI runners or developer machines. Tests that pass `isPi=true` to `LinuxSensors` and assert 0/empty returns are deterministic in practice; do not flag them as potentially flaky due to `vcgencmd` availability.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 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/hardware/common/platform/linux/LinuxCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.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/linux/LinuxCentralProcessor.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
📚 Learning: 2026-04-18T22:53:56.149Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:56.149Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
Applied to files:
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
🔇 Additional comments (4)
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java (1)
28-110: Great test split between fixture parsing and lightweight live checks.This gives deterministic parser coverage while still sanity-checking runtime command paths on Linux. Nice balance for reliability.
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java (1)
345-416: Solid fixture coverage for both extractedlscpuparsers.The NUMA and cache tests hit the critical parsing paths, including empty/comment-only input and
ways: nullhandling.oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java (1)
21-77: Nice deterministic coverage forvcgencmdparsing behavior.Good set of assertions across success, empty/short input, and invalid date fallback.
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java (1)
113-180: Clean extraction ofvcgencmdexecution from parsing.The new list-based parser overload and
VcGenCmdStringsaccessors make this path straightforward to test while preserving behavior in the no-arg path.
Working set memory can fluctuate significantly between the two reads, especially on CI. Widen ratio tolerance from 0.50 to 0.90 to prevent flaky failures.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3201 +/- ##
===========================================
- Coverage 58.17% 24.35% -33.82%
===========================================
Files 421 421
Lines 20336 20351 +15
Branches 3575 3576 +1
===========================================
- Hits 11830 4957 -6873
- Misses 6750 14826 +8076
+ Partials 1756 568 -1188
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java (1)
66-69: Optional: replace duplicated0.90with a named constant.This would make intent clearer and keep tuning centralized if thresholds change again.
♻️ Suggested cleanup
@@ - private static final long ZERO_TOLERANCE_BYTES = 1024L * 1024L; + private static final long ZERO_TOLERANCE_BYTES = 1024L * 1024L; + private static final double MEMORY_GAUGE_ALLOWED_VARIATION = 0.90; @@ - assertWithinRatio(p.getWorkingSetSize(), r.getWorkingSetSize(), 0.90, + assertWithinRatio(p.getWorkingSetSize(), r.getWorkingSetSize(), MEMORY_GAUGE_ALLOWED_VARIATION, "process[" + pid + "].workingSetSize"); - assertWithinRatio(p.getPrivateWorkingSetSize(), r.getPrivateWorkingSetSize(), 0.90, + assertWithinRatio(p.getPrivateWorkingSetSize(), r.getPrivateWorkingSetSize(), + MEMORY_GAUGE_ALLOWED_VARIATION, "process[" + pid + "].privateWorkingSetSize");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java` around lines 66 - 69, Replace the duplicated literal 0.90 used in the two assertWithinRatio calls with a named constant defined in the test class (e.g., double WORKING_SET_RATIO = 0.90 or private static final double ASSERT_WITHIN_RATIO = 0.90) and then use that constant in the calls to assertWithinRatio(p.getWorkingSetSize(), r.getWorkingSetSize(), WORKING_SET_RATIO, ...) and assertWithinRatio(p.getPrivateWorkingSetSize(), r.getPrivateWorkingSetSize(), WORKING_SET_RATIO, ...); keep the constant scope static/final so it’s easy to tune and clearly documents the intent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java`:
- Around line 66-69: Replace the duplicated literal 0.90 used in the two
assertWithinRatio calls with a named constant defined in the test class (e.g.,
double WORKING_SET_RATIO = 0.90 or private static final double
ASSERT_WITHIN_RATIO = 0.90) and then use that constant in the calls to
assertWithinRatio(p.getWorkingSetSize(), r.getWorkingSetSize(),
WORKING_SET_RATIO, ...) and assertWithinRatio(p.getPrivateWorkingSetSize(),
r.getPrivateWorkingSetSize(), WORKING_SET_RATIO, ...); keep the constant scope
static/final so it’s easy to tune and clearly documents the intent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5665e11a-6d55-4463-8309-81458e8d8308
📒 Files selected for processing (9)
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.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/util/driver/linux/Dmidecode.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
🧰 Additional context used
🧠 Learnings (8)
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.javaoshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.javaoshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-15T04:56:18.352Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3163
File: oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java:97-103
Timestamp: 2026-04-15T04:56:18.352Z
Learning: In CoreFoundationTest.java (oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java), asserting exact CFGetRetainCount deltas (+1 after retain, -1 after release) is intentional and considered reliable for freshly created CF objects (e.g., CFStringRef via CFStringRef.createCFString) where the test holds sole ownership. Do not flag these assertions as flaky — the Apple "avoid CFGetRetainCount" advisory applies to shared/framework-managed objects, not exclusively owned objects in unit tests.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java
📚 Learning: 2026-04-14T23:28:18.252Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3160
File: oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxSensorsTest.java:34-40
Timestamp: 2026-04-14T23:28:18.252Z
Learning: In oshi/oshi, `vcgencmd` (used in `LinuxSensors.queryCpuTemperatureFromVcGenCmd()` and related methods) is a Raspberry Pi-specific binary. It will never be present on standard x86/amd64 CI runners or developer machines. Tests that pass `isPi=true` to `LinuxSensors` and assert 0/empty returns are deterministic in practice; do not flag them as potentially flaky due to `vcgencmd` availability.
Applied to files:
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
📚 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/hardware/common/AbstractGlobalMemory.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.javaoshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.javaoshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.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/linux/LinuxCentralProcessor.java
📚 Learning: 2026-04-18T22:53:56.149Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:56.149Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.
Applied to files:
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java
🔇 Additional comments (9)
oshi-benchmark/src/test/java/oshi/comparison/RegistryComparisonTest.java (1)
65-69: Good call widening the memory-gauge tolerance for CI variability.This keeps the comparison meaningful while reducing flaky failures on rapidly changing process memory metrics.
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxCentralProcessor.java (1)
324-416: Nice separation of command execution from NUMA/cache parsing.This extraction is clean and keeps behavior intact while making the parsing paths directly unit-testable.
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java (1)
345-416: Great fixture coverage for the newlscpuparsing overloads.The added cases cover nominal input plus empty/comment-only and null-associativity scenarios effectively.
oshi-common/src/main/java/oshi/util/driver/linux/Dmidecode.java (1)
66-148: Clean extraction with a useful BIOS-revision robustness improvement.Delegating execution to
List<String>parsers is well done, and the case-insensitive revision lookup is a practical hardening step.oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java (1)
28-110: Solid parser-focused test refresh.These fixture-driven tests and edge cases make the dmidecode parsing behavior much more deterministic and maintainable.
oshi-common/src/main/java/oshi/hardware/common/AbstractGlobalMemory.java (1)
25-63: Good fix for DIMM field state isolation across banks.Resetting per-bank parsed fields here prevents value carryover and makes multi-entry parsing behavior correct and predictable.
oshi-common/src/test/java/oshi/hardware/common/AbstractGlobalMemoryTest.java (1)
54-132: Excellent regression coverage for physical-memory parsing.The new cases verify both normal parsing and the non-leak behavior between DIMM entries.
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxFirmware.java (1)
113-181: Nicevcgencmdparser extraction and encapsulation cleanup.The list-based parser and getter-backed value flow are clear and make the firmware parsing path much easier to test.
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxFirmwareTest.java (1)
21-77: Great deterministic coverage forvcgencmdparsing.These tests exercise happy-path and edge-path parsing in a clean, stable way.
Resolves part of #3189.
Separates command execution from output parsing in 7 methods across 4 classes, enabling deterministic testing with fixture data:
Refactored methods:
Dmidecode.querySerialNumber(),queryUUID(),queryBiosNameRev()—dmidecode -t system/-t biosAbstractGlobalMemory.getPhysicalMemory()—dmidecode --type 17LinuxFirmware.queryVcGenCmd()—vcgencmd version(Raspberry Pi)LinuxCentralProcessor.mapNumaNodesFromLscpu()—lscpu -p=cpu,nodeLinuxCentralProcessor.mapCachesFromLscpu()—lscpu -B -C --jsonEach method now has a package-private overload accepting
List<String>, with the public method delegating after running the command.Tests added:
DmidecodeTest— 7 new fixture-based tests for serial number, UUID, BIOS name/revisionAbstractGlobalMemoryTest— 3 tests (two DIMMs, single DIMM, empty input)LinuxFirmwareTest— 7 tests (vcgencmd parsing, empty input, invalid dates)LinuxCentralProcessorTest— 5 tests (NUMA node mapping, cache parsing)No public API changes. No new dependencies.
Summary by CodeRabbit
Refactor
Bug Fixes
Tests