private static void validateSeedBrokers ( String [ ] seedBrokers , Exception exception ) { if ( ! ( exception instanceof ClosedChannelException ) ) { return ; } int unknownHosts = 0 ; for ( String broker : seedBrokers ) { URL brokerUrl = NetUtils . getCorrectHostnamePort ( broker . trim ( ) ) ; try { InetAddress . getByName ( brokerUrl . getHost ( ) ) ; } catch ( UnknownHostException e ) { unknownHosts ++ ; } } // throw meaningful exception if all the provided hosts are invalid if ( unknownHosts == seedBrokers . length ) { throw new IllegalArgumentException ( "All the servers provided in: '" + ConsumerConfig . BOOTSTRAP_SERVERS_CONFIG + "' config are invalid. (unknown hosts)" ) ; } }
Validate that at least one seed broker is valid in case of a ClosedChannelException .