Resolve Hostnames Before Comparing to Active Server#2
Conversation
|
@claude review |
|
Claude finished @scottf's task in 1m 39s —— View job Code Review
SummaryThis PR improves host comparison in
|
|
@claude There was a bit of a re-write after the first review. Please re-review |
|
Claude finished @scottf's task in 3m 2s —— View job Code Re-Review
SummaryThe rewrite is a significant improvement. The previous NPE in Previous Issues — Status✅ NPE in
|
| test | active | action |
|---|---|---|
| hostname | hostname | only direct-string equality (by design — discovery never produces hostname-to-hostname) |
| hostname | IP | resolve test hostname; check if active IP is in the resolved set |
| IP | hostname | resolve active hostname; check if test IP is in the resolved set |
| IP | IP | only direct-string equality |
The comment in isEquivalent explains the design rationale clearly.
_resolveHostToIps lazy resolution from isEquivalent path
When isEquivalent is called for a host not yet in the cache (e.g., a peer discovered after startup), _resolveHostToIps will call pool.resolveHostToIps() synchronously from within peekNextServer()/nextServer(). A slow or timing-out DNS call here will delay the reconnection. The existing initialize() call pre-populates the cache for known servers, which is a mitigation — but newly discovered peers (which NATS reports as IPs) will skip the IP-resolution guard and also be skipped by the test.hostIsIpAddress() / active.hostIsIpAddress() branch, so this only triggers in the hostname-vs-IP case with an uncached hostname. Worth being aware of.
ApTests.java changes look correct
Adding a third server ensures the passive candidate is always distinct from the active server, and changing RECONNECTED + RESUBSCRIBED to CONNECTED fixes the event sequence to match actual reconnection behavior. Both changes address real test reliability issues.
Test Suite Quality
The new ApPassiveServerPoolTests.java is thorough — 7 sections (A–G), 19 tests, deterministic FakeServerPool. Good coverage of the cache, traversal loop-around, and pass-through delegation. One gap: no concurrent-access test, which would be the natural companion to a ConcurrentHashMap fix.
Overall
Blocking concern: the resolveMode null guard (minor risk but cheap fix). The thread-safety issue is a pre-existing risk worth addressing before merge. Everything else looks good.
initialize is called directly after init (create) because it's the only way to initialize a promised no-op contructor This is a NON ISSUE. |
|
Claude finished @scottf's task in 50s —— View job Response to
|
No description provided.