@Override
            protected SelectionKey registerChannel(String id, SocketChannel socketChannel, int interestedOps) throws IOException {
                SelectionKey key = super.registerChannel(id, socketChannel, interestedOps);
                key.cancel();
                if (throwIOException.get())
                    throw new IOException("Test exception");
                return key;
            }
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