Repository navigation
Hoist the NetworkIF enumeration loop into AbstractNetworkIF - #3455
Conversation
Every platform's getNetworks(boolean) hand-rolled the same loop: enumerate getNetworkInterfaces(includeLocal), construct the platform-specific NetworkIF for each, and log+skip any that fail to instantiate. Only the constructed type (and, for Mac/Aix, some pre-queried bulk data) differed. SolarisNetworkIF already had a local NetworkIFFactory + getNetworks(boolean, factory) helper; promote it to AbstractNetworkIF and adopt it everywhere. The simple platforms delegate with a constructor reference; Mac and AIX capture their pre-queried data (interface stats) in the factory lambda. Solaris's local copy is removed in favor of the inherited one. Along the way this unifies an inconsistency: LinuxNetworkIFFFM and LinuxNetworkIfNF logged e.toString() while every other platform logged e.getMessage(); the shared helper uses getMessage() for all. Now-orphaned LOG fields are dropped. No user-facing change. NetworkIF JNA==FFM comparison passes.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
💤 Files with no reviewable changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (12)
🧰 Additional context used🧠 Learnings (3)📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
🔇 Additional comments (12)
📝 WalkthroughWalkthroughNetwork interface enumeration now uses a shared factory-based helper in ChangesNetwork interface enumeration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
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 #3455 +/- ##
============================================
- Coverage 74.68% 74.65% -0.03%
Complexity 76 76
============================================
Files 584 584
Lines 21923 21862 -61
Branches 3679 3671 -8
============================================
- Hits 16373 16321 -52
+ Misses 3508 3495 -13
- Partials 2042 2046 +4
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:
|
Summary
First slice of Item 6 (NetworkIF) in the cross-OS dedup audit. Every platform's
getNetworks(boolean)hand-rolled the identical enumeration loop — walkgetNetworkInterfaces(includeLocal), construct the platform-specificNetworkIFfor each, and log+skip any that throwInstantiationException. Only the constructed type differed (and, for Mac/AIX, some pre-queried bulk data).SolarisNetworkIFalready proved the fix with a localNetworkIFFactory+getNetworks(boolean, factory)helper. This promotes that helper up toAbstractNetworkIFand adopts it across all ~14 implementations.Changes
AbstractNetworkIF: add theNetworkIFFactoryfunctional interface + sharedgetNetworks(boolean, factory)(using the existingLOGandgetNetworkInterfaces).return getNetworks(includeLocal, LinuxNetworkIFJNA::new);return getNetworks(includeLocal, ni -> new MacNetworkIfJNA(ni, data));LinuxNetworkIFFFMandLinuxNetworkIfNFloggede.toString()while everyone else loggede.getMessage(); the shared helper usesgetMessage()for all. Now-orphanedLOGfields dropped.Net −132 lines (13 files); ~14 copies of the loop → one helper.
Behavior
No user-facing change — same enumeration, same skip-on-failure semantics; only that one debug-log line is unified.
Testing
install: BUILD SUCCESS, 0 tests failedNativeComparisonTestNetworkIF JNA==FFM comparison: passes on macOSFollow-ups (queued, separate PRs)
The fatter per-platform native
updateAttributes/model logic is left for follow-ups (they need native-call abstraction, not a mechanical hoist): the Linux udev model lookup, and the Mac/Windows/AIX stat queries. NoteWindowsNetworkIfJNA.updateAttributeshas a Vista-gated legacy path (MIB_IFROW2vsMIB_IFROW) — a target for the seam + differential-legacy-test pattern (cf. #3454) when that PR lands.Summary by CodeRabbit