Repository navigation
Add missing WMI and perfmon driver comparison tests - #3213
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📜 Recent 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)
🧰 Additional context used🧠 Learnings (15)📓 Common learnings📚 Learning: 2026-04-18T03:18:06.205ZApplied to files:
📚 Learning: 2026-04-19T01:28:47.155ZApplied to files:
📚 Learning: 2026-04-17T23:56:46.416ZApplied to files:
📚 Learning: 2026-04-15T04:56:18.352ZApplied to files:
📚 Learning: 2026-04-18T22:53:56.149ZApplied to files:
📚 Learning: 2026-04-17T23:52:55.560ZApplied to files:
📚 Learning: 2026-04-05T05:39:21.126ZApplied to files:
📚 Learning: 2026-04-05T16:15:06.124ZApplied to files:
📚 Learning: 2026-04-05T05:40:45.797ZApplied to files:
📚 Learning: 2026-04-18T23:21:43.993ZApplied to files:
📚 Learning: 2026-04-08T00:58:10.736ZApplied to files:
📚 Learning: 2026-04-06T22:30:07.083ZApplied to files:
📚 Learning: 2026-04-10T22:44:36.786ZApplied to files:
📚 Learning: 2026-03-29T20:03:00.830ZApplied to files:
🔇 Additional comments (5)
📝 WalkthroughWalkthroughAdds new JUnit comparison tests in oshi-benchmark that validate parity between JNA and FFM implementations for Perfmon thread-counter filtering and multiple WMI queries (process command-lines, XP processes, LHM/OHM sensors, GPU/hardware lists, and MSFTStorage datasets). Changes
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)
✏️ 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3213 +/- ##
==========================================
+ Coverage 61.28% 61.49% +0.21%
==========================================
Files 423 423
Lines 20371 20371
Branches 3572 3572
==========================================
+ Hits 12484 12528 +44
+ Misses 6104 6060 -44
Partials 1783 1783
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.
Actionable comments posted: 2
🤖 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-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`:
- Line 186: The assertion comparing exact filtered thread instance lists is
flaky because snapshots are live; in PerfmonComparisonTest replace the strict
equality assertion on ffm.getA() vs jna.getA() with a volatility-tolerant check
(e.g., assert that both are empty or both non-empty by comparing
ffm.getA().isEmpty() to jna.getA().isEmpty(), or check only size parity) and
keep the existing key-set assertion on Line 185; update the assertion that
currently uses containsExactlyInAnyOrderElementsOf to a parity-based assertion
using ffm.getA() and jna.getA().
In `@oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`:
- Around line 389-406: The tests testWin32ProcessCommandLines and
testWin32ProcessXP are flaky because they call Win32_Process twice (via
Win32ProcessJNA.queryCommandLines/queryProcesses and
Win32ProcessFFM.queryCommandLines/queryProcesses) with a null filter and then
assume index 0 matches; fix by filtering both queries to the same stable PID
(e.g., current JVM PID) and compare the matching entry rather than index 0: call
Win32ProcessJNA.queryCommandLines(...) and
Win32ProcessFFM.queryCommandLines(...) (and the corresponding queryProcesses
methods) with a filter for the current PID and, when asserting field equality
(e.g., PROCESSID), locate the row for that PID in each WmiResult before
comparing values to avoid ordering/race issues.
🪄 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: 9e420694-9ef8-4ce0-959e-b1dcf595fafd
📒 Files selected for processing (2)
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.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 21, windows-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
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.
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())`).
📚 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/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.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/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-17T23:56:46.416Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:46.416Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.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/PerfmonComparisonTest.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-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
🔇 Additional comments (3)
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java (3)
408-421: Good optional-source handling for LHM coverage.Line 410’s intent and the count-parity assertions in these two tests are a good fit for environments where LHM is absent or intermittently available.
423-450: Nice COM lifecycle hygiene in the OHM comparison test.The explicit handler setup plus
finallyuninitialization keeps this test robust and avoids COM state leakage across tests.
502-523: Great addition of missing MSFTStorage parity checks.These new assertions close the driver-comparison gap for storage pools/disks/relationships and align well with the existing count-based comparison style in this suite.
57c1f2a to
fbf5b54
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java (1)
407-410:⚠️ Potential issue | 🟠 MajorKeep the XP comparison on the same stable PID filter.
This still compares two live
Win32_Processsnapshots withnull, so the result count can drift independently of driver correctness. Reuse the filtered current-PID path here as well.🔧 Suggested fix
- WmiResult<ProcessXPProperty> jna = Win32ProcessJNA.queryProcesses(null); - WbemcliUtilFFM.WmiResult<ProcessXPProperty> ffm = Win32ProcessFFM.queryProcesses(null); - assertWithinRatio(ffm.getResultCount(), jna.getResultCount(), 0.1, "Win32Process XP count"); + long pid = ProcessHandle.current().pid(); + Assumptions.assumeTrue(pid <= Integer.MAX_VALUE, "Current PID does not fit in the query filter"); + Set<Integer> currentPid = Collections.singleton((int) pid); + WmiResult<ProcessXPProperty> jna = Win32ProcessJNA.queryProcesses(currentPid); + WbemcliUtilFFM.WmiResult<ProcessXPProperty> ffm = Win32ProcessFFM.queryProcesses(currentPid); + assertThat(ffm.getResultCount()).as("Win32Process XP count").isEqualTo(jna.getResultCount());🤖 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/WmiComparisonTest.java` around lines 407 - 410, The test testWin32ProcessXP currently queries live snapshots with null filters causing result drift; change both Win32ProcessJNA.queryProcesses(null) and Win32ProcessFFM.queryProcesses(null) to use the same current-PID filter used elsewhere in this file (the filtered current-PID path your other tests use) so both queries use an identical stable PID filter instead of null; update the two calls in testWin32ProcessXP to pass that filter object (the same variable or helper method used by the other Win32Process tests).
🤖 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-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`:
- Around line 393-395: Replace the silent fallback to PID 0 with a JUnit
assumption: in WmiComparisonTest, check the current process ID returned by
ProcessHandle.current().pid() with Assumptions.assumeTrue(pid <=
Integer.MAX_VALUE, "PID too large to fit in int") so the test is skipped when
the PID overflows; then build currentPid using (int) pid and pass it to
Win32ProcessJNA.queryCommandLines(...) instead of using 0. Ensure you import
org.junit.jupiter.api.Assumptions and update the currentPid construction
accordingly.
---
Duplicate comments:
In `@oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`:
- Around line 407-410: The test testWin32ProcessXP currently queries live
snapshots with null filters causing result drift; change both
Win32ProcessJNA.queryProcesses(null) and Win32ProcessFFM.queryProcesses(null) to
use the same current-PID filter used elsewhere in this file (the filtered
current-PID path your other tests use) so both queries use an identical stable
PID filter instead of null; update the two calls in testWin32ProcessXP to pass
that filter object (the same variable or helper method used by the other
Win32Process tests).
🪄 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: c2c26ffe-5ab6-4c24-9dad-030f06079b41
📒 Files selected for processing (2)
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.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 21, windows-latest
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 11, windows-latest
- 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: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
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.
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())`).
📚 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/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.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/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-17T23:56:46.416Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:46.416Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.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/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-17T23:52:55.560Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:55.560Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.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-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-05T05:39:21.126Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-05T16:15:06.124Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java:95-97
Timestamp: 2026-04-05T16:15:06.124Z
Learning: In `LinuxLogicalVolumeGroupJNA.getLogicalVolumeGroups()` (oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java), `physicalVolumesMap.get(e.getKey())` in the final stream mapping cannot return null: both `logicalVolumesMap` and `physicalVolumesMap` are populated via `computeIfAbsent` inside the same conditional block (`!Util.isBlank(vgName) && !Util.isBlank(lvName)`), so every VG key in `logicalVolumesMap` is guaranteed to have a corresponding entry in `physicalVolumesMap`. Do not flag this `.get()` call as a potential null-return issue. The FFM version uses `getOrDefault` as extra defensiveness, not because null is possible here.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-05T05:40:45.797Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:40:45.797Z
Learning: In OSHI's Linux FFM and JNA udev code, a null guard on `udev_enumerate_new()` is intentionally absent and should not be flagged. This is consistent across all four FFM classes (LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the JNA implementation (which also does not guard `enumerateNew()` for null). Per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` (which is guarded) implies `udev_enumerate_new()` will succeed. Adding a null guard would be both redundant and inconsistent with the established pattern.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.javaoshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-18T23:21:43.993Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32LogicalDisk.java:44-46
Timestamp: 2026-04-18T23:21:43.993Z
Learning: In OSHI's `Win32LogicalDisk.buildWmiClassNameWithWhere` (oshi-common), the `nameToMatch` parameter is always internally controlled (e.g., a drive name from a prior WMI query result), not arbitrary user input. Do not flag missing WQL escape sequences (backslash, single-quote) as a bug — the project maintainer (dbwiddis) confirmed only the existing double-quote escaping is needed.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-08T00:58:10.736Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:10.736Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java` and `oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java`, the `getPowerSources()` method intentionally returns a singleton list wrapping a single `getPowerSource("System Battery")` call, and the enumeration loop short-circuits after the first eligible battery pack. This matches the longstanding JNA behavior and is not a bug. A broader refactor to support zero-or-more batteries across both implementations is planned for a later date. Do not flag this as an issue.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-06T22:30:07.083Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3122
File: oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java:215-234
Timestamp: 2026-04-06T22:30:07.083Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java`, the `found` flag in `getControllerIdByLocation` is intentionally set to `true` as soon as either `vendor-id` or `device-id` is found in a matching service's parent. This is a deliberate design choice: a partial match (one of the two IDs) is preferred over continuing to iterate, because iterating further risks pairing IDs from two different and potentially mismatched services. Do not flag this as a bug or suggest splitting into separate `foundVendor`/`foundProduct` flags.
Applied to files:
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
🔇 Additional comments (4)
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java (3)
413-426: LGTM — these optional-driver checks are scoped well.Count parity is the right level here for LHM, since the software may simply not be installed on CI.
429-455: LGTM — COM lifetime is handled cleanly here.The explicit
finallycleanup keeps the handler state from leaking across the OHM queries.
475-528: LGTM — the MSFTStorage parity coverage fits the existing COM-managed block.The new pool, disk, and association comparisons extend the current JNA/FFM pattern without adding extra lifecycle risk.
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java (1)
178-187: LGTM — this keeps the filtered thread test volatility-tolerant.Key-set equality plus empty/non-empty parity avoids brittle instance matching while still checking JNA vs FFM shape.
- Win32Process: queryCommandLines and queryProcesses (XP) - MSFTStorage: StoragePools, PhysicalDisks, VirtualDisks, StoragePoolToPhysicalDisk (added to existing testDiskDrivers) - LhmSensor: querySensors and queryGpuHardware - OhmSensor/OhmHardware: querySensorValue and queryHwIdentifier - ThreadInformation: filtered queryThreadCounters overload
fbf5b54 to
b471061
Compare
Summary
Add direct JNA vs FFM comparison tests for all Windows drivers that were missing coverage:
WmiComparisonTest:
Win32Process:queryCommandLinesandqueryProcesses(XP)MSFTStorage: StoragePools, PhysicalDisks, VirtualDisks, StoragePoolToPhysicalDisk (added to existingtestDiskDrivers)LhmSensor:querySensorsandqueryGpuHardwareOhmSensor/OhmHardware:querySensorValueandqueryHwIdentifierPerfmonComparisonTest:
ThreadInformation: filteredqueryThreadCounters(name, pid)overloadThe OHM/LHM tests will return 0 results on CI (software not installed) but are present so developers can run them on hardware with those tools installed.
What was tested
spotless:apply— passcheckstyle:check— 0 violationsinstall(compile + test + package) — passforbiddenapis:check— passSummary by CodeRabbit