private void verifyImmediatelyConnectedException(Selector selector, String id) throws Exception {
        try {
            selector.connect(id, new InetSocketAddress("localhost", server.port), BUFFER_SIZE, BUFFER_SIZE);
            fail("Expected exception not thrown");
        } catch (Exception e) {
            verifyEmptyImmediatelyConnectedKeys(selector);
            assertNull(selector.channel(id), "Channel not removed");
            ensureEmptySelectorFields(selector);
        }
    }
Verify that if Selector#connect fails and throws an Exception, all related objects
are cleared immediately before the exception is propagated.
clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java