public static Socket acceptWithoutTimeout(ServerSocket serverSocket) throws IOException {
        Preconditions.checkArgument(
                serverSocket.getSoTimeout() == 0, "serverSocket SO_TIMEOUT option must be 0");
        while (true) {
            try {
                return serverSocket.accept();
            } catch (SocketTimeoutException exception) {
                // This should be impossible given that the socket timeout is set to zero
                // which indicates an infinite timeout. This is due to the underlying JDK-8237858
                // bug. We retry the accept call indefinitely to replicate the expected behavior.
            }
        }
    }
@Test
    void testAcceptWithoutTimeoutSuppressesTimeoutException() throws IOException {
        // Validates that acceptWithoutTimeout suppresses all SocketTimeoutExceptions
        Socket expected = new Socket();
        ServerSocket serverSocket =
                new ServerSocket() {
                    private int count = 0;

                    @Override
                    public Socket accept() throws IOException {
                        if (count < 2) {
                            count++;
                            throw new SocketTimeoutException();
                        }

                        return expected;
                    }
                };

        assertThat(NetUtils.acceptWithoutTimeout(serverSocket)).isEqualTo(expected);
    }