Skip to content

Stop AIX reporting the current instant as its boot time - #3561

Merged
dbwiddis merged 3 commits into
oshi:masterfrom
dbwiddis:aix-boot-time-resilience
Aug 2, 2026
Merged

dbwiddis merged 3 commits into
oshi:masterfrom
dbwiddis:aix-boot-time-resilience

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

An AIX CI run reported Uptime: 0 days, 00:00:02 and a boot time twenty seconds in the past, four minutes after the same box had correctly reported 166 days. The machine had not rebooted — the serial number and UUID are identical across both readings, and it is at 169 days now.

The zero-uptime fallback

AixOperatingSystem derived its boot time as currentTimeMillis() - Uptime.queryUpTime(). That query returns 0 both when the system just booted and when the uptime command could not be run, so a transient failure on a loaded shared box produced a boot time of "now" and an uptime of zero.

Two things made that worse than a one-off bad reading:

  • The value was cached in a static final field computed at class load, so a single failure poisoned the boot time for the life of the JVM.
  • Class load happens during test startup, when the machine is busiest.

resolveBootTimeMillis now treats a zero uptime as unknown rather than as a valid duration, and the cache stores only a successful reading, so a failed query is retried on the next call. The cache stays static so the JNA and FFM backends report an identical boot time rather than each deriving one from a separately-timed reading of a minute-resolution source — NativeComparisonTest asserts they are equal.

The uptime command is now preferred over who -b: it reports a duration, which is unambiguous, where who -b reports a timestamp whose AIX format may carry no year.

The who -b format has never parsed on AIX

who -b on AIX 7.3 prints, in both the C and en_US locales:

   .        system boot Feb 13 23:31

BOOT_FORMAT_AIX has only ever matched a four-digit yyyy-MM-dd date — in every revision since the original 2020 AIX port, confirmed with git log -p. So the primary source has never parsed on this box, leaving the uptime command as the only one. Both forms are now accepted. The year-less one resolves to the most recent occurrence, which cannot disambiguate a system up more than a year, and is why it is consulted only after the unambiguous duration.

Hoisting rather than duplicating

Resolving a year-less timestamp already existed in the generic UNIX who reader, which parses the same MMM d HH:mm form. Rather than write a second copy, the logic is hoisted to ParseUtil.parseYearlessDateToEpoch and both drivers call it.

That also fixes a latent bug in the generic reader: its default year was captured in a static formatter when the class loaded, so it would have gone stale in a JVM running across a new year.

AGENTS.md gains a note to check ParseUtil before writing a parsing helper — this duplication was easy to miss because the two copies lived in per-platform drivers nobody would read side by side.

Verification

Checked against the real gcc119 AIX 7.3.0.0 box over ssh. The test fixture is the exact line it emits, trailing padding included, captured with who -b | od -c. Locale sensitivity was ruled out by running who -b under both LC_ALL=C and LC_ALL=en_US.

Full gate green on all 8 modules: spotless, checkstyle, install, forbiddenapis, javadoc, and 1504 tests successful / 0 failed.

The AIX-specific paths cannot be exercised by CI on this host; the parse seams are covered by fixture tests, and the cfarm AIX job will exercise the rest.

Summary by CodeRabbit

  • Bug Fixes

    • Improved AIX boot-time and uptime detection, including support for boot timestamps without a year.
    • Uses reliable uptime data when available and falls back to boot records when necessary.
    • Prevents incorrect uptime values when boot time cannot be determined.
    • Improved handling of yearless Unix session timestamps, including year rollover, leap days, and invalid input.
  • Documentation

    • Added release notes covering the AIX boot-time and uptime improvements.

An AIX CI run reported "Uptime: 0 days, 00:00:02" and a boot time twenty
seconds in the past, four minutes after the same box had correctly
reported 166 days. The machine had not rebooted: the serial number and
UUID are identical across both readings, and it is at 169 days now.

AixOperatingSystem derived its boot time as currentTimeMillis() minus
Uptime.queryUpTime(). That query returns 0 both when the system just
booted and when the uptime command could not be run, so a transient
failure on a loaded shared box produced a boot time of "now" and an
uptime of zero. Because the value was cached in a static final field
computed at class load, one such failure poisoned the boot time for the
life of the JVM. It also happened at the worst possible moment, during
test startup when the machine is busiest.

resolveBootTimeMillis now treats a zero uptime as unknown rather than as
a valid duration, and the cache stores only a successful reading, so a
failed query is retried on the next call. The cache stays static so the
JNA and FFM backends report an identical boot time rather than each
deriving one from a separately-timed reading of a minute-resolution
source; NativeComparisonTest asserts they are equal.

The uptime command is now preferred over who -b. It reports a duration,
which is unambiguous, where who -b reports a timestamp whose AIX format
may carry no year.

That format is the second half of the problem. who -b on AIX 7.3 prints

    .        system boot Feb 13 23:31

in both the C and en_US locales, but BOOT_FORMAT_AIX has only ever
matched a four-digit yyyy-MM-dd date, in every revision since the
original 2020 AIX port. The primary source has therefore never parsed on
this box, leaving the uptime command as the only one. Both forms are now
accepted; the year-less one resolves to the most recent occurrence,
which is why it is consulted only after the unambiguous duration.

Resolving a year-less timestamp already existed in the generic UNIX who
reader, which parses the same MMM d HH:mm form, so rather than write a
second copy the logic is hoisted to ParseUtil.parseYearlessDateToEpoch
and both drivers call it. That also fixes a latent bug in the generic
reader, whose default year was captured in a static formatter when the
class loaded and so would have gone stale in a JVM running across a new
year.

Verified against the real gcc119 AIX 7.3.0.0 box over ssh; the fixture
in the test is the exact line it emits, trailing padding included,
captured with who -b | od -c.
@coderabbitai

coderabbitai Bot commented Aug 2, 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: 30a0771a-0c1d-43b7-be66-84ad8e162523

📥 Commits

Reviewing files that changed from the base of the PR and between d8f5ea3 and 00ebd15.

📒 Files selected for processing (1)
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)

📝 Walkthrough

Walkthrough

Changes

AIX boot-time and date parsing

Layer / File(s) Summary
Shared yearless date parsing
oshi-common/src/main/java/oshi/util/ParseUtil.java, oshi-common/src/main/java/oshi/util/driver/unix/Who.java, oshi-common/src/test/java/oshi/util/ParseUtilTest.java, AGENTS.md, config/checkstyle-suppressions.xml
ParseUtil now performs strict yearless timestamp conversion. The Unix who reader uses it. Tests cover year selection, leap days, defaults, and invalid input. Repository guidance documents reuse of this parser.
AIX yearless boot parser
oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java, oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
The AIX parser accepts yearless month-name timestamps and preserves four-digit year parsing. Tests cover current-year and previous-year resolution.
AIX boot-time resolution and cache
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java, oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixOperatingSystemTest.java, CHANGELOG.md
Boot-time lookup lazily caches successful results, prefers uptime-derived values, and falls back to valid who -b output. Unavailable boot time produces zero uptime.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AixOperatingSystem
  participant UptimeSource
  participant AixWho
  AixOperatingSystem->>UptimeSource: read uptime
  alt positive uptime-derived boot time
    UptimeSource-->>AixOperatingSystem: boot time
  else uptime unavailable
    AixOperatingSystem->>AixWho: read who -b boot time
    AixWho-->>AixOperatingSystem: parsed boot time
  end
  AixOperatingSystem-->>AixOperatingSystem: cache first successful value
Loading

Possibly related PRs

  • oshi/oshi#3469: Both changes modify AIX boot-time and uptime handling.
  • oshi/oshi#3501: Both changes modify AIX Who.parseBootTime and its tests.

Poem

A rabbit parses dates by moonlight bright,
Yearless stamps now land just right.
AIX checks uptime, then who -b,
And caches the first success it can see.
Hop, hop—boot time is known!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% 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 describes the main AIX boot-time detection fix.
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: 2

🤖 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 `@CHANGELOG.md`:
- Line 3: Change the “Bug Fixes and Improvements” heading in CHANGELOG.md from a
fifth-level heading to a second-level heading, using ## to maintain the correct
Markdown heading hierarchy.

In `@oshi-common/src/main/java/oshi/util/ParseUtil.java`:
- Around line 1583-1585: Update the yearless-date resolution around
LocalDateTime.parse so future or invalid current-year candidates are reparsed
with the previous year instead of using minusYears(1), preserving Feb 29 when
valid there. Return 0 if both the current-year and previous-year parses fail,
and add a regression test covering Feb 29 in a non-leap current year.
🪄 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 Plus

Run ID: 9ebefd85-83f0-4e8c-90ab-f320b9786fd9

📥 Commits

Reviewing files that changed from the base of the PR and between a50c1cc and 59c8306.

📒 Files selected for processing (9)
  • AGENTS.md
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixOperatingSystemTest.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{java,xml,md}

📄 CodeRabbit inference engine (AGENTS.md)

Do not commit generated output, target/, or IDE files.

Files:

  • AGENTS.md
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixOperatingSystemTest.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
CHANGELOG.md

📄 CodeRabbit inference engine (AGENTS.md)

Add an entry under Next Release only for user-visible changes; omit pure refactors, deduplication, test-only changes, and CI configuration.

Files:

  • CHANGELOG.md
oshi-common/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-common/**/*.java: Keep oshi-common pure Java: do not reference JNA, FFM, or System.load/loadLibrary; place parsing, conversion, validation, caching, and shared logic there rather than duplicating it in platform implementations.
Use Java 8-compatible language features in oshi-common; do not use modern Java 9+ syntax or APIs.

Files:

  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixOperatingSystemTest.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*.java: Use oshi.util.ParseUtil parsing helpers instead of Integer.parseInt, Long.parseLong, Double.parseDouble, Integer.decode, and related banned APIs.
Do not use org.slf4j.event.**; use oshi.util.LogLevel instead.
Every public member must have Javadoc, and code and Javadoc—including {@link ...}—must use imported simple class names rather than fully qualified names.
New classes should declare an appropriate concurrency annotation from oshi.annotation.concurrent, matching the modeled class where applicable.
Wrap constant or expensive, slowly changing system values in oshi.util.Memoizer.memoize, using defaultExpiration() when refresh is required.
Avoid timing-sensitive assertions comparing live readings such as CPU frequency, tick counters, or uptime.

Files:

  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixOperatingSystemTest.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
**/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

Prefer native calls for system information; on Linux prefer FileUtil for /proc and /sys, while on other platforms ExecutingCommand is acceptable when native APIs do not expose the information.

Files:

  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
**/driver/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

Put platform-specific acquisition and command matching in drivers, but reuse ParseUtil for general parsing primitives instead of creating duplicate parsers.

Files:

  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
**/*Test.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*Test.java: Use JUnit 5 and Hamcrest; do not add Mockito. Separate parsing from acquisition so parser methods can be tested with fixture List<String> or String input.
Test invariants such as non-null values, types, ordering, and plausible ranges rather than hardware-specific values; allow zero and empty results.

Files:

  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixOperatingSystemTest.java
🧠 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/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.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/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.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/util/ParseUtil.java
  • oshi-common/src/main/java/oshi/util/driver/unix/Who.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixOperatingSystem.java
🪛 markdownlint-cli2 (0.23.1)
CHANGELOG.md

[warning] 3-3: Heading levels should only increment by one level at a time
Expected: h2; Actual: h5

(MD001, heading-increment)

Comment thread CHANGELOG.md Resolved
@codecov

codecov Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.76744% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.27%. Comparing base (a50c1cc) to head (00ebd15).

Files with missing lines Patch % Lines
...oftware/common/os/unix/aix/AixOperatingSystem.java 25.00% 12 Missing ⚠️
...ommon/src/main/java/oshi/util/driver/unix/Who.java 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3561      +/-   ##
============================================
- Coverage     79.36%   79.27%   -0.09%     
- Complexity     3789     4143     +354     
============================================
  Files           706      706              
  Lines         24264    24292      +28     
  Branches       4057     4063       +6     
============================================
+ Hits          19257    19258       +1     
- Misses         2820     2846      +26     
- Partials       2187     2188       +1     
Flag Coverage Δ
freebsd 32.80% <69.76%> (+0.02%) ⬆️
linux 36.82% <69.76%> (+0.06%) ⬆️
macos 37.70% <69.76%> (-0.02%) ⬇️
openbsd 31.91% <69.76%> (+0.04%) ⬆️
solaris 33.31% <69.76%> (+0.04%) ⬆️
windows 44.59% <69.76%> (-0.02%) ⬇️

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.

CodeRabbit flagged February 29 in parseYearlessDateToEpoch, and the
problem is worse than a failed parse. DateTimeFormatter defaults to
ResolverStyle.SMART, which silently clamps an out-of-range day rather
than rejecting it, so "Feb 29" resolved against a non-leap current year
produced February 28 of that year -- a wrong date, quietly, with no
exception for the caller to react to. Confirmed against the JDK: SMART
gives 2025-02-28, LENIENT gives 2025-03-01, only STRICT throws.

The parse is now STRICT, and a candidate that is invalid or lands in the
future is reparsed with the previous year rather than having a year
subtracted from it. Subtracting would have hit the same clamp from the
other direction, turning a valid February 29 into the 28th. A leap day
valid in neither candidate year now yields 0 rather than a plausible
wrong answer.

Reachable in the generic UNIX who reader, where a session that began on
February 29 and is read during the following non-leap year would have
been reported a day early, and in the AIX who -b path added in this
branch.

Also fixes the spotless violation in ParseUtilTest that failed lint: the
last edit landed after the final spotless:apply.

The checkstyle suppression for ParseUtil's legacy lowercase Pattern
constants is keyed to line numbers, so the added ResolverStyle import
shifted "slash" out of the range and failed ConstantName. Bounds updated
and commented to say so.

@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.

🧹 Nitpick comments (1)
oshi-common/src/test/java/oshi/util/ParseUtilTest.java (1)

1019-1036: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a non-leap invalid-date fixture.

The leap-day cases cover one invalid calendar date. Add a case such as Apr 31 where both candidate years are invalid and the result must be 0L. This protects the strict parsing contract from future lenient normalization.

Proposed test
+        assertThat("Parse invalid date when neither candidate year is valid",
+                ParseUtil.parseYearlessDateToEpoch("Apr 31 12:00", "MMM d HH:mm", now), is(0L));
🤖 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/test/java/oshi/util/ParseUtilTest.java` around lines 1019 -
1036, Add a ParseUtil.parseYearlessDateToEpoch test alongside the existing
leap-day cases using an invalid date such as “Apr 31” with a current date whose
current and previous candidate years both apply; assert the result is 0L,
preserving strict rejection rather than lenient normalization.
🤖 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.

Nitpick comments:
In `@oshi-common/src/test/java/oshi/util/ParseUtilTest.java`:
- Around line 1019-1036: Add a ParseUtil.parseYearlessDateToEpoch test alongside
the existing leap-day cases using an invalid date such as “Apr 31” with a
current date whose current and previous candidate years both apply; assert the
result is 0L, preserving strict rejection rather than lenient normalization.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: da8d5032-0330-48a3-858c-2d7bf01eed5d

📥 Commits

Reviewing files that changed from the base of the PR and between 59c8306 and d8f5ea3.

📒 Files selected for processing (3)
  • config/checkstyle-suppressions.xml
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
📜 Review details
⏰ Context from checks skipped due to timeout. (11)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, ubuntu-latest
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
📓 Path-based instructions (3)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

Do not commit generated output, target/, or IDE files.

Files:

  • config/checkstyle-suppressions.xml
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
oshi-common/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-common/**/*.java: Keep oshi-common pure Java 8: it must not reference JNA, FFM, or native loading APIs; shared parsing, conversion, validation, caching, and string logic belongs here rather than duplicated in platform implementations.
Use oshi.util.ParseUtil parsing helpers instead of banned numeric parsing APIs such as Integer.parseInt, Long.parseLong, Double.parseDouble, and Integer.decode.
Do not import org.slf4j.event.**; use oshi.util.LogLevel instead.
Prefer hoisting non-native logic into oshi-common so JNA and FFM implementations share parsing, conversion, validation, sorting, filtering, caching, and sentinel handling instead of duplicating it.
Add runtime configuration to oshi-common/src/main/resources/oshi.properties and access it through oshi.util.GlobalConfig; do not introduce a separate configuration mechanism.

Files:

  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
**/*Test.java

📄 CodeRabbit inference engine (AGENTS.md)

Use JUnit 5 and Hamcrest; do not add Mockito. Extract parsing from acquisition so parsing methods accept fixture data such as List<String> or String and acquisition methods remain thin.

Files:

  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: oshi/oshi

Timestamp: 2026-08-02T16:49:58.420Z
Learning: Before final verification, rebuild from the repository root with the relevant dependency modules included (`clean install` or `-am`) to avoid stale `oshi-common` artifacts from `~/.m2`.
Learnt from: CR
Repo: oshi/oshi

Timestamp: 2026-08-02T16:49:58.420Z
Learning: Before opening a PR, run formatting, Checkstyle, install, forbidden-API checks, and Javadoc generation in that order for touched modules.
Learnt from: CR
Repo: oshi/oshi

Timestamp: 2026-08-02T16:49:58.420Z
Learning: Do not add dependencies without discussion or manually bump dependency versions; Renovate manages dependency updates.
Learnt from: CR
Repo: oshi/oshi

Timestamp: 2026-08-02T16:49:58.420Z
Learning: Branch from `master`, target PRs at `master`, describe what changed and why in commit messages, and do not add sign-off or `Co-Authored-By` trailers unless requested.
🔇 Additional comments (3)
oshi-common/src/test/java/oshi/util/ParseUtilTest.java (2)

998-1017: LGTM!


1037-1041: LGTM!

config/checkstyle-suppressions.xml (1)

11-13: LGTM!

CodeRabbit nit: the leap-day cases only cover a date that is valid in
some years, so they would still pass if the resolver merely happened to
reject February 29. Apr 31 exists in no year, and the default resolver
normalizes it to April 30 rather than rejecting it (LENIENT gives May 1;
only STRICT throws), so this pins the strict behavior for the general
invalid-date case.

Test-only.
@dbwiddis
dbwiddis merged commit 140a84b into oshi:master Aug 2, 2026
26 of 27 checks passed
@dbwiddis
dbwiddis deleted the aix-boot-time-resilience branch August 2, 2026 17:25
dbwiddis added a commit that referenced this pull request Aug 2, 2026
The line ranges in checkstyle-suppressions.xml broke last week: adding an
import to ParseUtil shifted its lowercase Pattern constants out of
lines="117-136", and ConstantName failed on a constant the change never
touched. Both remaining ranges are gone, and three drift-proof
mechanisms are enabled to replace them.

SuppressWarningsFilter/SuppressWarningsHolder honor
@SuppressWarnings("checkstyle:CheckName") on a declaration.
SuppressionCommentFilter gives CHECKSTYLE:OFF/ON around a contiguous
region, which is what ParseUtil's six constants and MacOperatingSystem's
four protected fields now use -- a region survives edits both above and
inside it, where a line count does not. SuppressWithNearbyCommentFilter
covers one-offs. Verified by deleting the markers: 10 violations return
(6 ConstantName, 4 VisibilityModifier), 0 with them.

The Sonar comments had drifted into four spellings: NOSONAR squid:Sxxxx,
NOSONAR:squid:S5843 with a stray colon, NOSONAR java:Sxxxx, and a bare
NOSONAR with no rule recorded at all. All are now
"// NOSONAR java:Sxxxx - why", on the modern prefix (squid: was retired
years ago; S00107 also becomes S107).

The two bare ones were identified from their code: a hardcoded 0.0.0.0
is S1313, and catch (Throwable) is S1181, matching how the same patterns
are already marked elsewhere.

Two comments in AdlUtilFFM and BStrFFM described a suppression in prose
and so contained the word NOSONAR, which silently suppressed their own
line. Reworded to say "the suppression on the next line".

AGENTS.md documents both conventions, including two things worth
knowing: NOSONAR suppresses every issue on its line regardless of the
rule id written after it, which is documentation only and not parsed; and
@SuppressWarnings is rule-scoped and preferred where there is something
to annotate, but is not honored for S3077.

Also fixes the five open Sonar issues, all java:S8694 from #3561's own
test using int month literals where ParseUtilTest used Month constants.

Left alone: two bare NOSONAR comments on the Addrinfo try-with-resources
in MacNetworkParamsJNA and FreeBsdNetworkParamsJNA. The rule is not
determinable from the code and Sonar retains no history for either file,
so naming one would be a guess. Drop the suppression and read the next
scan to resolve them.
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