Skip to content

Make @ThreadSafe HAL snapshot fields volatile/final for safe publication - #3489

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:threadsafe-volatile-stat-fields
Jul 19, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:threadsafe-volatile-stat-fields

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Honor the @ThreadSafe contract on OSHI's mutable-snapshot HAL classes by giving their fields proper cross-thread visibility and safe publication.

These classes (OSProcess, OSThread, and NetworkIF families, plus the dynamic CentralProcessor frequency/cache fields) are annotated @ThreadSafe but are populated at construction and refreshed by public updateAttributes() / updateNetworkStats() calls, then read via getters with no memory synchronization. A concurrent refresh and read could observe stale, torn, or half-updated values — violating the annotation's contract ("no caller synchronization required").

  • volatile on 112 reassigned mutable stat fields — per-field visibility without locking the hot read path
  • final on 12 write-once memoize(...) Supplier fields (matching e.g. MacCentralProcessor.vendor, which was already final)

No behavior change and no locks added; this is a pure visibility/publication hardening.

CodeQL findings cleared

Clears three CodeQL Reliability categories for these classes in a single fix (volatile satisfies all three, final covers the write-once Suppliers):

  • Not thread-safe — field access unprotected by a monitor
  • Safe publication — non-final/non-volatile field not safely published
  • Escaping — non-final protected field potentially escaping

The WmiQueryHandlerFFM findings in these categories are false positives (its state is a ConcurrentHashMap-backed set and synchronized/volatile primitives) and are dismissed separately.

Testing

./mvnw clean install (full reactor) plus spotless, checkstyle, forbiddenapis, and javadoc all pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved consistency of hardware, process, and thread details when accessed concurrently by ensuring updated values are reliably visible across threads (including network, CPU, and OS process/thread attributes).
  • Refactor
    • Strengthened thread-safety guarantees by tightening internal state mutability/visibility (e.g., making stable identifiers immutable and using volatile for frequently refreshed metrics) without changing public APIs or expected behavior.

The mutable HAL/OS snapshot classes (OSProcess, OSThread, NetworkIF, and the
dynamic CentralProcessor frequency/cache fields) are annotated @threadsafe but
populated at construction and refreshed by public updateAttributes()/
updateNetworkStats() calls, then read via getters with no memory
synchronization. A concurrent refresh and read could observe stale, torn, or
half-updated values, violating the @threadsafe contract.

Mark each reassigned mutable stat field volatile, and mark the write-once
memoize() Supplier fields final. This gives per-field visibility and safe
publication without introducing locking on the hot read path.

Clears the CodeQL Reliability findings "Not thread-safe", "Safe publication",
and "Escaping" for these classes.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9cc67452-ddb0-415b-b43d-b4ea379452a4

📥 Commits

Reviewing files that changed from the base of the PR and between ee7f4e9 and 406b511.

📒 Files selected for processing (3)
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (12)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.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/windows/WindowsCentralProcessor.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
🔇 Additional comments (2)
oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java (1)

44-53: LGTM!

Also applies to: 57-66

oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java (1)

43-43: LGTM!

Also applies to: 59-59, 139-147


📝 Walkthrough

Walkthrough

The pull request updates hardware, processor, process, and thread state fields for cross-thread visibility. It also makes selected identity and memoized supplier fields final, and publishes the Windows NUMA mapping only after complete construction.

Changes

Concurrency visibility updates

Layer / File(s) Summary
Hardware state visibility
oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java, oshi-common/src/main/java/oshi/hardware/common/platform/*/*NetworkIF.java, oshi-common/src/main/java/oshi/hardware/common/platform/*/*CentralProcessor.java
Network metadata and statistics fields gain volatile visibility, network identity fields become final, and the Windows NUMA map is fully built locally before volatile publication.
Shared process and thread state
oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java, oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
Common process and thread identity, status, timing, and counter fields become volatile; the process ID becomes final.
Platform process caches
oshi-common/src/main/java/oshi/software/common/os/**/*OSProcess.java
Platform-specific process metrics and cached attributes gain volatile visibility; Linux memoized suppliers become final.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • oshi/oshi#3390: Defines shared process fields updated by this change.
  • oshi/oshi#3391: Refactors shared network-interface state touched here.
  • oshi/oshi#3446: Refactors shared thread fields updated with volatile visibility.

Poem

A rabbit watched the fields align,
With volatile flags in every line.
The NUMA map bloomed, then took its place,
While threads saw state at rabbit pace.
“Hop hooray!” I squeaked with grace.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making @ThreadSafe HAL snapshot fields volatile/final for safe publication.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java (1)

44-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer final over volatile for fields initialized only in the constructor.

These fields are private and are only assigned once during object construction. Declaring them final provides stronger immutability guarantees, ensures safe publication across threads without the overhead of volatile reads, and clearly communicates their read-only nature.

♻️ Proposed refactor
-    private volatile NetworkInterface networkInterface;
-    private volatile String name;
-    private volatile String displayName;
-    private volatile int index;
-    private volatile long mtu;
-    private volatile String mac;
-    private volatile String[] ipv4;
-    private volatile Short[] subnetMasks;
-    private volatile String[] ipv6;
-    private volatile Short[] prefixLengths;
+    private final NetworkInterface networkInterface;
+    private final String name;
+    private final String displayName;
+    private final int index;
+    private final long mtu;
+    private final String mac;
+    private final String[] ipv4;
+    private final Short[] subnetMasks;
+    private final String[] ipv6;
+    private final Short[] prefixLengths;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java` around
lines 44 - 53, Update the constructor-initialized fields in
AbstractNetworkIF—networkInterface, name, displayName, index, mtu, mac, ipv4,
subnetMasks, ipv6, and prefixLengths—from volatile to final, preserving their
existing constructor assignments and read-only behavior.
oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java (1)

59-59: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant volatile modifier.

utilityBaseMultiplier is exclusively read and written within the synchronized lazilyCalculateMultiplier method. Because all accesses are already guarded by the same intrinsic lock, the JMM already guarantees visibility and atomicity. The volatile modifier here is redundant and can be omitted.

♻️ Proposed fix
-    private volatile Long utilityBaseMultiplier;
+    private Long utilityBaseMultiplier;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java`
at line 59, Remove the redundant volatile modifier from the
utilityBaseMultiplier field. Keep the field’s Long type and rely on the existing
synchronized lazilyCalculateMultiplier method for all accesses.
oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java (1)

25-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer final for immutable identity fields.

Unlike the other statistical properties that are updated during refresh, processID is exclusively set in the constructor and never mutated. Marking it as final provides stronger initialization safety and clearly conveys intent, rendering the volatile modifier unnecessary.

♻️ Proposed fix
-    private volatile int processID;
+    private final int processID;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java` at
line 25, Change the processID field in AbstractOSProcess from volatile to final,
preserving its constructor initialization and all existing read behavior. Remove
the unnecessary volatile modifier and ensure no refresh or other code path
attempts to reassign this immutable identity field.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java`:
- Line 43: Update buildNumaNodeProcMap() to populate a local HashMap completely
before assigning it to numaNodeProcToLogicalProcMap. Keep the volatile field
assignment as the final step so readers only observe a fully initialized map.

---

Nitpick comments:
In `@oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java`:
- Around line 44-53: Update the constructor-initialized fields in
AbstractNetworkIF—networkInterface, name, displayName, index, mtu, mac, ipv4,
subnetMasks, ipv6, and prefixLengths—from volatile to final, preserving their
existing constructor assignments and read-only behavior.

In
`@oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java`:
- Line 59: Remove the redundant volatile modifier from the utilityBaseMultiplier
field. Keep the field’s Long type and rely on the existing synchronized
lazilyCalculateMultiplier method for all accesses.

In `@oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java`:
- Line 25: Change the processID field in AbstractOSProcess from volatile to
final, preserving its constructor initialization and all existing read behavior.
Remove the unnecessary volatile modifier and ensure no refresh or other code
path attempts to reassign this immutable identity field.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d5919c16-1929-4cf5-8620-27b1efd04950

📥 Commits

Reviewing files that changed from the base of the PR and between a848adb and ee7f4e9.

📒 Files selected for processing (14)
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
  • oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractNetworkIF.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/AbstractOSThread.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/windows/WindowsCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java
🔇 Additional comments (11)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java (1)

23-26: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java (1)

21-21: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java (1)

23-27: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java (1)

83-84: LGTM!

oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisOSProcess.java (1)

42-45: LGTM!

oshi-common/src/main/java/oshi/software/common/os/windows/WindowsOSProcess.java (1)

58-71: LGTM!

oshi-common/src/main/java/oshi/software/common/AbstractOSThread.java (1)

28-50: LGTM!

oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java (1)

79-99: LGTM!

oshi-common/src/main/java/oshi/software/common/os/unix/AbstractProcOSProcess.java (1)

52-58: LGTM!

oshi-common/src/main/java/oshi/software/common/os/mac/MacOSProcess.java (1)

63-76: LGTM!

oshi-common/src/main/java/oshi/software/common/os/unix/bsd/BsdOSProcess.java (1)

44-53: LGTM!

@codecov

codecov Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.87%. Comparing base (a848adb) to head (ee7f4e9).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3489      +/-   ##
============================================
+ Coverage     71.57%   74.87%   +3.30%     
  Complexity       76       76              
============================================
  Files           591      591              
  Lines         21583    21583              
  Branches       3614     3614              
============================================
+ Hits          15448    16161     +713     
+ Misses         4240     3447     -793     
- Partials       1895     1975      +80     
Flag Coverage Δ
freebsd 27.72% <27.27%> (-0.01%) ⬇️
linux 32.27% <63.63%> (-0.01%) ⬇️
macos 32.82% <27.27%> (-0.05%) ⬇️
openbsd 27.03% <27.27%> (?)
solaris 29.39% <27.27%> (-0.05%) ⬇️
windows 40.87% <63.63%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

… map

- AbstractNetworkIF: the 10 constructor-only fields (networkInterface, name,
  displayName, index, mtu, mac, ipv4, subnetMasks, ipv6, prefixLengths) are
  write-once, so mark them final rather than volatile.
- AbstractOSProcess.processID: write-once identity field -> final.
- WindowsCentralProcessor.utilityBaseMultiplier: drop the redundant volatile;
  every access is already inside the synchronized lazilyCalculateMultiplier.
- WindowsCentralProcessor.buildNumaNodeProcMap: build the map in a local
  variable and publish it to the volatile field as the final step, so readers
  never observe a partially populated map.
@dbwiddis
dbwiddis merged commit 9bb6307 into oshi:master Jul 19, 2026
17 of 18 checks passed
@dbwiddis
dbwiddis deleted the threadsafe-volatile-stat-fields branch July 19, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant