#vulnerable code 
                                @Test
    public void testExpiredIteratorException() {
        log.info("Starting tests");
        when(getRecordsRetrievalStrategy.getRecords(MAX_RECORDS_PER_CALL)).thenThrow(ExpiredIteratorException.class)
                .thenReturn(getRecordsResponse);

        getRecordsCache.start(sequenceNumber, initialPosition);

        doNothing().when(dataFetcher).restartIterator();

        getRecordsCache.getNextResult();

        sleep(1000);

        verify(dataFetcher).restartIterator();
    } 
                            #location 11 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                @Test
    public void testExpiredIteratorException() {
        log.info("Starting tests");
        when(getRecordsRetrievalStrategy.getRecords(MAX_RECORDS_PER_CALL)).thenThrow(ExpiredIteratorException.class)
                .thenReturn(getRecordsResponse);

        getRecordsCache.start(sequenceNumber, initialPosition);

        doNothing().when(dataFetcher).restartIterator();

        blockUntilRecordsAvailable(() -> getRecordsCache.pollNextResultAndUpdatePrefetchCounters(), 1000L);

        sleep(1000);

        verify(dataFetcher).restartIterator();
    }