KafkaURI { public boolean resolveURI() { if (resolved) return true; for (String uri : bootstrapURIs) { int index = uri.indexOf(':'); if (index == -1) throw new Error("invalid kafka uri, uri=" + uri); String host = uri.substring(0, index); var address = new InetSocketAddress(host, 9092); if (!address.isUnresolved()) { resolved = true; return true; } } return false; } KafkaURI(String uri); boolean resolveURI(); @Override String toString(); final List<String> bootstrapURIs; }
@Test void resolveURI() { assertThat(new KafkaURI("localhost").resolveURI()).isTrue(); }