I'm personally not thrilled with interleaving the string processing and the lookup code.  Could we refactor a little bit?

```java
SortedSet<HostAndPort> addresses = Sets.newTreeSet();
for (InetSocketAddress address : ...) {
  try {
    for (InetAddress address : ...) {
      addresses.add(HostAndPort.fromParts(address.getHostName(), port));
    }
  } catch (...) {
    addresses.add(HostAndPort.fromString(...));
  }
}

return ADDRESS_JOINER.join(addresses);  // HostAndPort has a reasonable toString()
```