public Iterator<ReadRowsResponse> readRows()
    {
        List<ReadRowsResponse> readRowResponses = new ArrayList<>();
        long readRowsCount = 0;
        int retries = 0;
        Iterator<ReadRowsResponse> serverResponses = fetchResponses(request);
        while (serverResponses.hasNext()) {
            try {
                ReadRowsResponse response = serverResponses.next();
                readRowsCount += response.getRowCount();
                readRowResponses.add(response);
            }
            catch (RuntimeException e) {
                // if relevant, retry the read, from the last read position
                if (BigQueryUtil.isRetryable(e) && retries < maxReadRowsRetries) {
                    request.getReadPositionBuilder().setOffset(readRowsCount);
                    serverResponses = fetchResponses(request);
                    retries++;
                }
                else {
                    // to safely close the client
                    try (BigQueryStorageClient ignored = client) {
                        throw e;
                    }
                }
            }
        }
        return readRowResponses.iterator();
    }
@Test
    void testRetryOfSingleFailure()
    {
        MockResponsesBatch batch1 = new MockResponsesBatch();
        batch1.addResponse(Storage.ReadRowsResponse.newBuilder().setRowCount(10).build());
        batch1.addException(new StatusRuntimeException(Status.INTERNAL.withDescription(
                "Received unexpected EOS on DATA frame from server.")));
        MockResponsesBatch batch2 = new MockResponsesBatch();
        batch2.addResponse(Storage.ReadRowsResponse.newBuilder().setRowCount(11).build());

        ImmutableList<Storage.ReadRowsResponse> responses = ImmutableList.copyOf(
                new MockReadRowsHelper(client, request, 3, ImmutableList.of(batch1, batch2))
                        .readRows());

        assertThat(responses.size()).isEqualTo(2);
        assertThat(responses.stream().mapToLong(Storage.ReadRowsResponse::getRowCount).sum()).isEqualTo(21);
    }