Commit d3004aa
Don't cache failed DNS lookups in the desktop client
When a laptop wakes from sleep, transient DNS resolution failures get
cached by Java's InetAddress cache. Our continuous polling loop then
hits the cached failure faster than the 10s default negative TTL can
expire, wedging the client at "connecting…" until the user restarts
it. The OS resolver is fine — `host vcell-dev.cam.uchc.edu` returns
the correct IP — but the JVM never re-queries it.
Set Security properties at the top of main(), before any DNS lookup:
- networkaddress.cache.ttl=30 (modest positive cache, matches the
non-SecurityManager default but makes it explicit and stable)
- networkaddress.cache.negative.ttl=0 (never cache failures; recover
immediately when DNS comes back)
Asymmetric TTL is the established pattern for long-running JVMs that
need to recover from transient DNS issues — see AWS SDK and Oracle
networking-properties guidance. Programmatic Security.setProperty is
the only reliable mechanism: -D JVM args don't bridge to security
properties, and -Dsun.net.inetaddr.ttl is undocumented in modern Java.
Observed in user log:
>> polling failure << vcell-dev.cam.uchc.edu: nodename nor servname
provided, or not known
(repeating, after laptop sleep/wake)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 210bb01 commit d3004aa
1 file changed
Lines changed: 8 additions & 0 deletions
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| |||
0 commit comments