public void poll(final long timeoutMs, final long currentTimeMs) {
        trySend(currentTimeMs);

        long pollTimeoutMs = timeoutMs;
        if (!unsentRequests.isEmpty()) {
            pollTimeoutMs = Math.min(retryBackoffMs, pollTimeoutMs);
        }
        this.client.poll(pollTimeoutMs, currentTimeMs);
        maybePropagateMetadataError();
        checkDisconnects(currentTimeMs);
    }
@Test
    public void testPropagateMetadataError() {
        AuthenticationException authException = new AuthenticationException("Test Auth Exception");
        doThrow(authException).when(metadata).maybeThrowAnyException();

        LinkedList<BackgroundEvent> backgroundEventQueue = new LinkedList<>();
        this.backgroundEventHandler = new BackgroundEventHandler(backgroundEventQueue);
        NetworkClientDelegate networkClientDelegate = newNetworkClientDelegate();

        assertEquals(0, backgroundEventQueue.size());
        networkClientDelegate.poll(0, time.milliseconds());
        assertEquals(1, backgroundEventQueue.size());

        BackgroundEvent event = backgroundEventQueue.poll();
        assertNotNull(event);
        assertEquals(BackgroundEvent.Type.ERROR, event.type());
        assertEquals(authException, ((ErrorEvent) event).error());
    }