Repository navigation
Fix Error Prone ERROR-severity findings, make error-prone job blocking - #3595
Conversation
…king - oshi-core-ffm: fix a latent bug in IPHlpAPIUtilFFM.getDnsServers() where the DNS-list loop's guard compared a MemorySegment by reference against MemorySegment.NULL, which a slice/reinterpret never actually equals even at address 0 - the condition was always true and the loop relied entirely on an inner break to terminate. No observable behavior change (the inner break already terminated correctly), but removes the risk of an infinite loop if that break is ever touched. Compare by .address() instead, matching the existing check already used later in the same loop. - oshi-demo: suppress BanJNDI in the JMX Client demo - it connects to OshiJMXServer, its own companion demo server on a hardcoded localhost address, not attacker-controlled input; JMX-over-RMI inherently resolves through JNDI. - oshi-benchmark: explicitly discard intentionally-unused return values in MonitoringFootprintReport (warm-up and graph-realization calls) using Java 21's unnamed variable syntax, matching Error Prone's own suggested fix. - Remove continue-on-error from the error-prone CI job now that the ERROR-severity backlog is clear; WARNING-severity findings still don't block, by javac's own default behavior.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (13)
🧰 Additional context used📓 Path-based instructions (2)**/*.{java,xml}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/pom.xml📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (6)📓 Common learnings📚 Learning: 2026-07-26T23:06:49.011ZApplied to files:
📚 Learning: 2026-08-05T23:44:09.936ZApplied to files:
📚 Learning: 2026-08-05T23:44:09.936ZApplied to files:
📚 Learning: 2026-08-05T23:44:09.936ZApplied to files:
📚 Learning: 2026-08-05T23:44:09.936ZApplied to files:
🔇 Additional comments (2)
📝 WalkthroughWalkthroughThe pull request makes Error Prone failures block CI, adjusts benchmark compiler settings, assigns discarded benchmark results locally, fixes native DNS pointer null checks, and documents the JMX demo’s localhost JNDI usage. ChangesBuild enforcement and warning fixes
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/pr.yaml:
- Around line 118-120: Update the Error Prone profile comment in pom.xml to
reflect that the profile is currently blocking for ERROR-severity findings while
WARNING-severity findings remain non-blocking; remove the stale “non-blocking
for now” wording, without changing the workflow or profile behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 51d672cd-78f0-4f4c-a329-0b9fa3ddf709
📒 Files selected for processing (4)
.github/workflows/pr.yamloshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.javaoshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.javaoshi-demo/src/main/java/oshi/demo/jmx/demo/Client.java
📜 Review details
⏰ Context from checks skipped due to timeout. (10)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 26, ubuntu-latest
- GitHub Check: Lint (Spotless, Checkstyle)
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Error Prone
- GitHub Check: Test JDK 21, ubuntu-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Analyze (java)
- GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.java
📄 CodeRabbit inference engine (AGENTS.md)
**/*.java: Do not use banned numeric parsing APIs such asInteger.parseInt,Long.parseLong,Double.parseDouble, orInteger.decode; use the appropriateoshi.util.ParseUtilmethod.
New classes should declare an appropriate concurrency annotation such as@ThreadSafe,@Immutable,@NotThreadSafe, or@GuardedBy, matching the modeled class where applicable.
Files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.javaoshi-demo/src/main/java/oshi/demo/jmx/demo/Client.javaoshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java
oshi-core-ffm/src/main/java/**/*.java
📄 CodeRabbit inference engine (AGENTS.md)
Do not reference
com.sun.jnafromoshi-core-ffm.
Files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
**/*.{java,md}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{java,md}: When changing a JNA or FFM implementation, apply the equivalent behavior change to its counterpart, or document why the implementations intentionally differ; prefer hoisting non-native-specific logic intooshi-common.
Use current-year-only copyright headers for new files (Copyright 2026 The OSHI Project ContributorsandSPDX-License-Identifier: MIT); do not commit generated output,target/, or IDE files.
Files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.javaoshi-demo/src/main/java/oshi/demo/jmx/demo/Client.javaoshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java
**/src/main/java/**/*.java
📄 CodeRabbit inference engine (AGENTS.md)
**/src/main/java/**/*.java: Every public and protected type and method needs valid Javadoc; use imported simple class names rather than fully qualified names, including in{@link}tags.
Memoize constant or expensive, slowly changing native-call results usingoshi.util.Memoizer, following the surrounding class anddefaultExpiration()conventions.
Prefer native calls for system information; on Linux preferFileUtilfor/procand/sys, whileExecutingCommandis acceptable on other platforms when native APIs do not expose the data.
Verify native struct offsets, field widths, andsysctl/ioctlconstants against the target OS and architecture; do not infer them from another operating system.
Files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.javaoshi-demo/src/main/java/oshi/demo/jmx/demo/Client.javaoshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java
**/*.{java,xml}
📄 CodeRabbit inference engine (AGENTS.md)
Do not add line-range Checkstyle suppressions. Prefer declaration-level
@SuppressWarnings, scoped Checkstyle comments, or file/package suppressions without line ranges; use Sonar@SuppressWarnings("java:Sxxxx")where possible and keep statement-level suppression comments short and justified.
Files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.javaoshi-demo/src/main/java/oshi/demo/jmx/demo/Client.javaoshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java
🧠 Learnings (9)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:26:05.716Z
Learning: In oshi/oshi, `oshi-common/src/main/java/oshi/util/ExceptionUtil.java`'s private `logAtLevel(Logger, Level, String, Throwable)` helper (and the similar pattern in `oshi-core-ffm/src/main/java/oshi/ffm/ForeignFunctions.java` and `oshi-core/src/main/java/oshi/util/platform/windows/PerfDataUtil.java`) intentionally calls SLF4J 1.x-compatible methods like `log.error(msg, t.getMessage(), t)` with a single `{}` placeholder in `msg` and the `Throwable t` as the trailing argument. This is not a bug: SLF4J's implicit-cause handling (since 1.6.0) detects a trailing `Throwable` argument and attaches it as the log event's cause with full stack trace, equivalent to the SLF4J 2.x-only `.atLevel(level).setCause(t).log(...)` fluent API that this PR deliberately avoids for SLF4J 1.x runtime compatibility. Do not flag these calls as losing the throwable cause/stack trace.
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.
Applied to files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.javaoshi-demo/src/main/java/oshi/demo/jmx/demo/Client.javaoshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java
📚 Learning: 2026-07-30T00:35:22.638Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:22.638Z
Learning: In OSHI, treat changes as “API-breaking” only when they affect classes (or relevant API surface) annotated with `PublicAPI`. Public classes/members that are not annotated with `PublicAPI` should be reviewed as internal implementation details, even if they are public (e.g., classes like `oshi.hardware.common.platform.unix.BsdFirmware`). Also, respect intentional visibility decisions used for tests—e.g., methods like `BsdFirmware.parseDmesg(List<String>)` may be intentionally package-private to support tests within the same package; avoid widening visibility or altering signatures unless the related `PublicAPI` contract requires it.
Applied to files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.javaoshi-demo/src/main/java/oshi/demo/jmx/demo/Client.javaoshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java
📚 Learning: 2026-08-02T23:56:23.866Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3565
File: oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/PosixLibcFunctions.java:51-56
Timestamp: 2026-08-02T23:56:23.866Z
Learning: For Java FFM bindings in the oshi-core-ffm module, assume a 64-bit JVM and 64-bit operating system. Do not flag 32-bit native ABI or memory-layout compatibility concerns, consistent with the project's JDK 25 support policy, unless that policy changes.
Applied to files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
📚 Learning: 2026-08-03T00:46:14.953Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3566
File: oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdNetworkParams.java:18-22
Timestamp: 2026-08-03T00:46:14.953Z
Learning: In the OSHI Java codebase, do not require duplicate Javadoc on public methods annotated with Override when the inherited Javadoc from the parent declaration adequately documents the method. The general public-member Javadoc requirement should not flag these overrides solely because they lack redundant documentation.
Applied to files:
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.javaoshi-demo/src/main/java/oshi/demo/jmx/demo/Client.javaoshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java
📚 Learning: 2026-05-31T05:53:04.246Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3311
File: .github/workflows/site.yaml:21-21
Timestamp: 2026-05-31T05:53:04.246Z
Learning: When a GitHub Actions workflow verifies that a pinned commit SHA matches a version tag, dereference annotated tags before comparing to a commit SHA. The API `GET /repos/{owner}/{repo}/git/refs/tags/{tag}` returns the tag *object* SHA for annotated tags (not the underlying commit SHA), so comparing it directly to a commit SHA will cause false mismatches. Instead: (1) fetch the tag object SHA via `GET /repos/{owner}/{repo}/git/refs/tags/{tag}`; (2) resolve that tag object to the underlying commit by calling `GET /repos/{owner}/{repo}/git/tags/{tag_object_sha}`; (3) compare the pinned commit SHA to the resolved commit at `.object.sha`.
Applied to files:
.github/workflows/pr.yaml
📚 Learning: 2026-07-21T20:38:16.728Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3509
File: oshi-demo/pom.xml:72-80
Timestamp: 2026-07-21T20:38:16.728Z
Learning: For the OSHI Maven/Jacoco CI workflows, coverage aggregation/report upload steps should run only when the test job succeeds (e.g., guard with conditions like `if: success()`). Do not add logic to generate/upload or preserve aggregate coverage artifacts after test failures, and avoid fragile/over-engineered handling of exit status unless there is an explicit separate project requirement.
Applied to files:
.github/workflows/pr.yaml
📚 Learning: 2026-05-04T04:58:36.843Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3227
File: oshi-metrics/src/main/java/oshi/metrics/OshiMetrics.java:35-48
Timestamp: 2026-05-04T04:58:36.843Z
Learning: In `oshi-metrics/src/main/java/oshi/metrics/OshiMetrics.java`, the `private final OperatingSystem os` field is intentionally stored in the constructor even though it is not yet used. It is a placeholder for future OS-level metrics (e.g., process metrics) that will be added incrementally. Do not flag it as dead code.
Applied to files:
oshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.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-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java
🔇 Additional comments (4)
.github/workflows/pr.yaml (1)
121-124: LGTM!Also applies to: 138-139
oshi-benchmark/src/main/java/oshi/benchmark/MonitoringFootprintReport.java (1)
74-74: 🎯 Functional CorrectnessRemove the preview-feature warning.
oshi-benchmarkcompiles with release 25 and runs on JDK 25.var _is not a preview feature at this release.> Likely an incorrect or invalid review comment.oshi-demo/src/main/java/oshi/demo/jmx/demo/Client.java (1)
48-54: LGTM!oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java (1)
97-97: LGTM!
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3595 +/- ##
============================================
- Coverage 79.89% 79.86% -0.03%
- Complexity 3873 4236 +363
============================================
Files 710 710
Lines 24242 24242
Branches 4052 4052
============================================
- Hits 19369 19362 -7
- Misses 2715 2722 +7
Partials 2158 2158
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The Error Prone CI job failed with "invalid flag: -Xep:InlineMeSuggester:OFF": oshi-benchmark's maven-compiler-plugin config forks a separate javac process for its JDK toolchain, and a forked invocation doesn't preserve a multi-option -Xplugin value as one command-line token the way in-process compilation does elsewhere in the reactor - it gets split apart, and Error Prone's own "-Xep:Check:OFF" flags aren't independently recognized by javac. Rather than plumb the -J-prefixed JVM flags a forked compile would need (since .mvn/jvm.config's JPMS opens don't propagate to a forked subprocess), exclude oshi-benchmark from the error-prone profile entirely via a matching-id profile override restoring the plain compilerArgs baseline: it's JMH-only, excluded from the release, and will never carry jSpecify annotations, so it isn't worth the extra plumbing. Simplified the root profile's compilerArgs accordingly - the generated-sources exclusion was only needed for oshi-benchmark's JMH-generated sources, the only annotation-processor-generated code in the reactor. Also updates the error-prone profile's comment, stale since ERROR-severity findings became blocking earlier in this PR.
Summary
Follow-on to #3594 (Error Prone groundwork). Fixes the small set of real ERROR-severity findings that tool surfaced, then removes
continue-on-error: truefrom theerror-proneCI job — from here on, ERROR-severity findings block the PR (javac's own default behavior for a compile error), while WARNING-severity findings still don't, and remain queued for the larger ongoing triage.oshi-core-ffm—IPHlpAPIUtilFFM.getDnsServers(): the DNS-list loop'swhileguard compared aMemorySegmentby reference againstMemorySegment.NULL. A.asSlice()/.get()/.reinterpret()result is never the literalNULLsingleton object, even at address 0, so the condition was always true and the loop's real termination relied entirely on an inner.address() == 0break already present a few lines down. No observable behavior change (that inner break already worked), but this removes the latent risk of an infinite loop if it's ever touched. Fixed to compare.address() != 0, matching the existing check already used later in the same loop. Checked the JNA twin (WindowsNetworkParamsJNA) — no equivalent bug there, since JNA's structure auto-mapping genuinely returns Javanullfor a null pointer field, unlike FFM'sMemorySegmentvalue type.oshi-demo— suppressesBanJNDIin the JMXClientdemo: it connects toOshiJMXServer, this demo's own companion server on a hardcodedlocalhost:8888, not attacker-controlled input. JMX-over-RMI inherently resolves through JNDI; there's no way to demonstrate this connectivity without it.oshi-benchmark—MonitoringFootprintReport: three call sites intentionally discard aFunction.apply()return value purely for its side effect (realizing a lazily-computed subsystem graph, or JIT/class-loading warm-up). Made the discard explicit with Java 21's unnamed-variable syntax (var _ = ...), matching Error Prone's own suggested fix text.continue-on-error: trueon theerror-pronejob now that the ERROR backlog is clear.No CHANGELOG entry — none of these are observable user-visible behavior changes (the FFM fix hardens a dead-condition risk without changing output; the rest is demo/benchmark code and CI config).
Test plan
./mvnw clean install -DskipTests -Perror-prone(whole reactor) — BUILD SUCCESS, 0 ERROR-severity findings (209 WARNING findings remain, queued for follow-on triage)./mvnw clean spotless:apply sortpom:sort checkstyle:check install forbiddenapis:check javadoc:javadoc— full gate passes, no reformatting needed./mvnw test -pl oshi-core-ffm -am— passesSummary by CodeRabbit
Bug Fixes
Developer Experience
Quality