Skip to content

Synchronize the network interface and power source refresh paths - #3654

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:network-sync
Aug 18, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:network-sync

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Third chunk of the updateAttributes() consistency arc, following #3586 and #3653. Same standard: the lock goes on the method that writes the fields, with no suppression beside it.

After this, every refreshable type is covered except OSProcess and OSThread.

NetworkIF: no shared writer, so seven locks

Unlike OSFileStore — where #3651 had already made AbstractOSFileStore the sole writer, so #3653 needed one edit for ten implementations — each NetworkIF platform class assigns the counters itself. Six take the lock on their own updateAttributes().

macOS shows why the writer is the right target

Its fields are written by updateNetworkStats(Map), which is reached from two places:

// the public refresh
public boolean updateAttributes() {
    return updateNetworkStats(queryIFdata(queryNetworkInterface().getIndex()));
}

// and the bulk list path, in MacNetworkIfJNA / MacNetworkIfFFM
public MacNetworkIfJNA(NetworkInterface netint, Map<Integer, IFdata> data) {
    super(netint, queryIfDisplayName(netint));
    updateNetworkStats(data);
}

Locking only updateAttributes() would leave the constructor path unguarded, so the lock goes on updateNetworkStats. That also keeps the native queryIFdata call outside the lock, since the public method queries first and writes after.

This is the same shape the arc flagged for OSProcess, where updateAttributes(Map) is called from subclass constructors and the public no-arg is the wrong place to lock.

Every platform reaches its writes from a constructor

Worth stating because it is easy to miss: the six oshi-common bases call updateAttributes() from their own constructors, and AIX and Solaris additionally call it from their JNA and FFM subclass constructors (AixNetworkIFJNA, AixNetworkIFFFM, SolarisNetworkIFJNA, SolarisNetworkIFFFM). All of those pass through the method now locked. Locking an object that has not been published yet is uncontended and harmless; leaving that path unlocked while locking the public one would not have been.

Locking safety

Checked rather than assumed, as in #3653:

  • No body acquires a second lock — no nested synchronized, no explicit Lock.
  • No call site sits inside a synchronized block.

So there is no ordering hazard.

PowerSource

The last interface carrying no thread-safety contract — OSProcess, OSThread, NetworkIF, HWDiskStore and now OSFileStore all have it. It gains the externally-synchronize paragraph, plus the one way it genuinely differs from the others: a failed update leaves the source unchanged, because it assigns nothing unless it finds a source matching this one's name. The other refreshable types set a sentinel or partial state on failure.

AbstractPowerSource.updateAttributes() is the sole writer and takes the lock.

Verification

Full gate and -Perror-prone clean, all tests passing. synchronized is not part of the method signature, so japicmp is unaffected. No CHANGELOG entry: this closes a race no OSHI-internal caller can reach, and the rest is documentation.

Summary by CodeRabbit

  • Bug Fixes
    • Improved thread safety when refreshing power-source information.
    • Improved thread safety for network interface statistics updates across supported platforms.
    • Prevented concurrent refresh operations from causing inconsistent attribute values.
  • Documentation
    • Added guidance on safely using power-source updates and their behavior when no matching source is found.

Third chunk of the updateAttributes() consistency arc, following #3653. Same
standard: the lock goes on the method that writes the fields, with no
suppression beside it.

NetworkIF has no shared writer, so six platforms take the lock on their own
updateAttributes(), which is where they assign the counters.

macOS is the exception and shows why the writer is the right target rather than
the public method. Its fields are written by updateNetworkStats(Map), reached
both from updateAttributes() and directly from the MacNetworkIfJNA and
MacNetworkIfFFM constructors, which populate an interface from a bulk query.
Locking only the public method would leave the constructor path unguarded, so
the lock goes on updateNetworkStats. That also keeps the native queryIFdata call
outside the lock, since updateAttributes queries first and writes after.

Every other platform reaches its writes from a constructor too -- the six
oshi-common bases from their own, and AIX and Solaris additionally from their
JNA and FFM subclasses -- and all of those go through the method now locked.
Verified no body acquires a second lock and no call site sits inside a
synchronized block, so there is no ordering hazard.

PowerSource was the last interface carrying no thread-safety contract. It gains
the externally-synchronize paragraph the other five have, plus the one way it
genuinely differs: a failed update leaves the source unchanged, because it
assigns nothing unless it finds a source matching this one's name.

With this the arc covers every refreshable type except OSProcess and OSThread.
@coderabbitai

coderabbitai Bot commented Aug 18, 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 Plus

Run ID: accde8c4-d640-4c22-93c3-c7dce902df3f

📥 Commits

Reviewing files that changed from the base of the PR and between 6c9e190 and 3a6651a.

📒 Files selected for processing (9)
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java

Included review availability: Your plan includes up to 8 reviews per rolling hour; 6 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (11)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 25, ubuntu-latest
  • GitHub Check: Test JDK 21, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle)
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Error Prone
  • GitHub Check: changes
  • GitHub Check: Analyze (java)
🧰 Additional context used
📓 Path-based instructions (3)
oshi-common/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-common/src/main/java/**/*.java: Before writing any parsing helper, check whether ParseUtil already has one.
oshi-common may not reference com.sun.jna.**, java.lang.foreign.**, or any
System.load/loadLibrary. It must stay pure JDK.

Files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
**/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/main/java/**/*.java: Javadoc. Every public and protected type and method needs javadoc.
Do not use fully-qualified class names in
code or in javadoc — including inside {@link ...}. Import the type and link the simple name.
New files get a current-year-only
header (Copyright 2026 The OSHI Project Contributors / SPDX-License-Identifier: MIT), even when
copied from an older file; spotless maintains end years on existing files.
Never add a line range to
config/checkstyle-suppressions.xml — a range breaks the moment anything above it shifts, including a
single added import, and the failure looks unrelated to the change that caused it.
new classes are
expected to declare one, and matching the annotation of the class you are modeling yours on is the
right default.
Do not reach for @Nullable to make a null return legal: the convention is a sentinel, not a
null
— Constants.UNKNOWN or "" for strings, an empty collection or array, and 0/-1/NaN
for numbers, whichever is outside the value's real range.
System calls are expensive, and callers poll. Values that are constant (CPU model,
serial number) or expensive-but-slow-changing are wrapped in
oshi.util.Memoizer.memoize(supplier, ...)

Files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
**

📄 CodeRabbit inference engine (AGENTS.md)

**: Do not add dependencies without discussion, and do not bump dependency versions by hand —
Renovate handles that.
Do not commit generated output, target/, or IDE files.

Files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
🧠 Learnings (6)
📚 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/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.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/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.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-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.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-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
📚 Learning: 2026-08-15T14:25:48.170Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3625
File: oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java:65-69
Timestamp: 2026-08-15T14:25:48.170Z
Learning: In OSHI Java code, treat `oshi.util.Util.isBlank(String)` as equivalent to `value == null || value.isEmpty()`: it does not consider whitespace-only strings blank. Do not report a behavior change when code replaces `!Util.isBlank(value)` with the equivalent `value != null && !value.isEmpty()` condition.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
📚 Learning: 2026-08-15T15:43:29.296Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3628
File: oshi-core-ffm/src/main/java/oshi/driver/windows/registry/HkeyUserDataFFM.java:108-108
Timestamp: 2026-08-15T15:43:29.296Z
Learning: In the OSHI Java codebase, use the sentinel-over-null convention at public API boundaries. Private helpers may return an explicitly JSpecify-annotated nullable value when the caller handles the missing result clearly and locally; callers must check for null before accessing the result. For example, methods such as lookupAccountBySid(String) may return String Nullable [] when queryUserSessions() performs the required null check.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java
  • oshi-common/src/main/java/oshi/hardware/PowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
🔇 Additional comments (9)
oshi-common/src/main/java/oshi/hardware/PowerSource.java (1)

43-47: LGTM!

oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java (1)

213-213: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java (1)

93-93: LGTM!

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

50-50: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdNetworkIF.java (1)

44-44: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixNetworkIF.java (1)

45-45: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdNetworkIF.java (1)

44-44: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/unix/solaris/SolarisNetworkIF.java (1)

46-46: LGTM!

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

86-86: LGTM!


📝 Walkthrough

Walkthrough

The change documents power-source update behavior and synchronizes power-source and platform-specific network-interface refresh methods. Existing data retrieval, field updates, failure handling, and return values remain unchanged.

Changes

Thread-safe hardware updates

Layer / File(s) Summary
Power source synchronization contract
oshi-common/src/main/java/oshi/hardware/PowerSource.java, oshi-common/src/main/java/oshi/hardware/common/AbstractPowerSource.java
The API documents synchronization requirements and unchanged-state behavior. updateAttributes() is synchronized.
Platform network refresh synchronization
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxNetworkIF.java, oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacNetworkIF.java, oshi-common/src/main/java/oshi/hardware/common/platform/unix/*NetworkIF.java, oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsNetworkIF.java
Platform-specific network refresh methods are synchronized. Existing statistics retrieval, parsing, field updates, and return behavior remain unchanged.

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

Merge Risk: ⚪ Minimal · up to 3a665

This PR synchronizes network interface and power source refresh writes to prevent concurrent state updates without changing the public behavior contract. No actionable merge-blocking risk remains; it is merge-ready after normal checks and review.

Possibly related PRs

  • oshi/oshi#3458: Both changes modify synchronization around updateAttributes and network-statistics update methods.

Poem

A rabbit checks the power flow,
While network counters safely grow.
Each refresh waits its proper turn,
No racing fields or values churn.
Synchronized, the metrics glow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.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 clearly and concisely describes the main changes: synchronizing network interface and power source refresh paths.
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.

@dbwiddis
dbwiddis merged commit 2ae2d00 into oshi:master Aug 18, 2026
16 of 17 checks passed
@dbwiddis
dbwiddis deleted the network-sync branch August 18, 2026 03:57
dbwiddis added a commit that referenced this pull request Aug 18, 2026
Final chunk of the updateAttributes() consistency arc begun in #3586, after
#3653 and #3654. Every refreshable type is now covered.

This is the phase the arc flagged as highest risk, for two reasons that both
turned out to be answered by locking the writer rather than the public method.

Where a class writes its fields in an overload -- AIX process, and Windows
process and thread -- the lock goes there, matching what #3586 did for the BSD
pair. That is not a stylistic choice: every one of those overloads is called
from a subclass constructor doing bulk population, so locking only the public
no-arg would leave the list-building path unguarded while appearing to cover it.

It also keeps the expensive work outside the lock. The Windows twins do all
their registry, performance counter and WTS querying in the public method before
delegating, so no WMI or COM call happens under the monitor -- verified, not
assumed. The BSD pair likewise spawns ps outside it.

Where a class writes inline instead, with no separate writer to target --
Solaris process and thread, Linux process and thread, AIX thread, and both macOS
process backends -- the no-arg takes the lock and its queries come with it.
macOS interleaves proc_pidinfo, proc_pidpath and getpwuid with the assignments,
so there is nothing to separate; this matches the six NetworkIF platforms in
#3654.

WindowsOSThreadJNA and WindowsOSThreadFFM need nothing: they write no fields and
delegate to the base overload now locked.

Verified no locked body acquires a second lock, so there is no ordering hazard.

Not included: hoisting BsdOSProcess.monotonic to share with AixHWDiskStore's
inline clamps, the arc's last open item. Both are now lock-protected, so it is
purely a duplication question, and it needs a home neutral to both hierarchies.
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