Repository navigation
Fix two xrandr follow-ups from the getConnectionPort work - #3679
Conversation
`UnixDisplay.getOutputName()` called `Xrandr.findOutputName()`, which ran `xrandr --verbose` itself, unmemoized. Every call on every display forked a process and reparsed the whole output, so naming the outputs of an n-display system cost n invocations, and did so again on each subsequent call. `findOutputName()` now takes the parsed xrandr data instead of fetching it, making it a pure function, and `UnixDisplay` holds the supplier it reads from. `getDisplays(List<Triplet<...>>)` builds a batch around one memoized query, so the batch costs at most one invocation however many displays it holds and however often they are asked; the xrandr fallback `getDisplays()` hands its displays the map it already realized, so they query nothing further. The memoization is indefinite rather than expiring: a `Display` is an immutable snapshot, so the output name matching its connector cannot change over the object's lifetime, and the hardware abstraction layer already re-queries the display list on its own schedule, rebuilding the batch with a fresh supplier. Also drops a null check on `findOutputName()`'s `edid` parameter, dead under the package's `@NullMarked` contract, and adds unit tests for the matching logic, which was previously unreachable from a test without a live X server.
#3660 tightened the xrandr EDID block detection from a `startsWith("EDID")` prefix test to an exact match on `EDID:`, so a property whose name merely contains EDID -- `EDID_HASH:` on some drivers -- could no longer be mistaken for the EDID itself. That was the right fix for the false positive, but it also dropped the two names an older X server publishes the EDID under: - `RANDR_EDID` (`RR_PROPERTY_RANDR_EDID`), the conventional property name randrproto used before 1.3 renamed it to `EDID`. - `EDID_DATA`, the driver-side atom (`EDID_ATOM_NAME` in `hw/xfree86/modes/xf86Crtc.c`) X.Org Server set through 1.6. Both are still what `xrandr --verbose` prints on those servers, and OSHI matched them before #3660 by prefix, so a display on one now reports no EDID at all. Match the three names exactly instead, keeping the false positive out.
|
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 (5)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (11)
🧰 Additional context used📓 Path-based instructions (4)oshi-common/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*Test.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/test/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (2)📚 Learning: 2026-08-15T04:17:20.334ZApplied to files:
📚 Learning: 2026-08-03T00:46:14.953ZApplied to files:
🔇 Additional comments (5)
📝 WalkthroughWalkthroughThe change adds memoized xrandr data sharing across Unix displays, supports additional EDID property names, updates Linux display construction, and adds coverage for lazy lookup, shared queries, parsing, and output matching. ChangesUnix display discovery
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change localizes xrandr query handling and restores support for legacy EDID property names, with no actionable merge-blocking risk remaining after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3679 +/- ##
============================================
+ Coverage 80.21% 80.23% +0.02%
- Complexity 4289 4649 +360
============================================
Files 707 707
Lines 25532 25541 +9
Branches 4302 4303 +1
============================================
+ Hits 20480 20493 +13
+ Misses 2838 2828 -10
- Partials 2214 2220 +6
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:
|
Two follow-ups deliberately deferred from #3660, both in
oshi-commonand both affecting the Linux/Unix display path only. NoCHANGELOG.mdentry: both defects live in code #3660 introduced, which is unreleased.1. Share one xrandr query among a batch of displays
UnixDisplay.getOutputName()calledXrandr.findOutputName(), which ranxrandr --verboseitself, unmemoized. Naming the outputs of an n-display system therefore forked n processes and reparsed the whole output n times — and did it again on every subsequent call.findOutputName()now takes the parsed data instead of fetching it, which also makes it a pure function, andUnixDisplayholds the supplier it reads from.getDisplays(List<Triplet<…>>)builds a batch around one memoized query, so a batch costs at most one invocation however many displays it holds and however often they are asked; thexrandrfallbackgetDisplays()hands its displays the map it already realized, so they query nothing further.The memoization is indefinite rather than expiring, because a
Displayis an immutable snapshot — the output name matching its connector cannot change over the object's lifetime — andAbstractHardwareAbstractionLayeralready re-queries the display list atslowExpiration(), rebuilding the batch with a fresh supplier. A topology change is still picked up at the same cadence as before.This also drops a null check on the
edidparameter that is dead under the package's@NullMarkedcontract, and adds unit tests for the connector-ID/EDID matching logic, which previously could not be reached from a test without a live X server.2. Accept the legacy EDID property names an older X server publishes
#3660 tightened EDID block detection from a
startsWith("EDID")prefix test to an exact match onEDID:, so that a property merely containingEDID—EDID_HASH:on some drivers — could no longer be mistaken for the EDID itself. That was the right fix for the false positive, but it also dropped the two names an older X server publishes the EDID under:RANDR_EDID(RR_PROPERTY_RANDR_EDID) — the conventional property name randrproto used before 1.3 renamed it toEDID.EDID_DATA— the driver-side atom (EDID_ATOM_NAMEinhw/xfree86/modes/xf86Crtc.c) that X.Org Server set through 1.6.Both are still what
xrandr --verboseprints on those servers, and OSHI matched them by prefix before #3660, so a display on one now reports no EDID at all. This matches the three names exactly, keeping the false positive out, and pins all four cases with tests.Verification
Full gate green locally on macOS (
spotless,sortpom,checkstyle,install,forbiddenapis,javadoc,-Paggregate-coverage; 1801 tests, 0 failures), plus-Perror-pronewith no NullAway findings. Linux CI green on all eight jobs on the fork (run). The batch-sharing test was negative-tested — dropping thememoizemakes it fail with 4 queries instead of 1.I have no X server running against a pre-1.7 X.Org Server, so the two legacy property names are verified against fixture data and the upstream source history rather than a live server.
Summary by CodeRabbit
Bug Fixes
Performance
Tests