#vulnerable code 
                                @Test
    public void testInterruptedExceptionDealtWith() throws InterruptedException
    {
        final boolean[] caught = {false};
        final InterruptedException[] ie = {null};
        int timeout = 1000;

        Thread t = new Thread(() ->
        {
            try
            {
                @SuppressWarnings("unchecked") TransferQueue<FakeResponse> fakeQueue =
                        (TransferQueue<FakeResponse>) mock(TransferQueue.class);
                when(fakeQueue.poll(timeout,
                                    TimeUnit.MILLISECONDS)).thenThrow(new InterruptedException(
                        "foo"));

                @SuppressWarnings("unchecked") PBStreamingFutureOperation<FakeResponse, Void, Void>
                        coreFuture = (PBStreamingFutureOperation<FakeResponse, Void, Void>) mock(
                        PBStreamingFutureOperation.class);

                when(coreFuture.getResultsQueue()).thenReturn(fakeQueue);

                // ChunkedResponseIterator polls the response queue when created,
                // so we'll use that to simulate a Thread interrupt.
                new ChunkedResponseIterator<>(coreFuture,
                                              timeout,
                                              Long::new,
                                              FakeResponse::iterator);
            }
            catch (RuntimeException ex)
            {
                caught[0] = true;
                ie[0] = (InterruptedException) ex.getCause();
            }
            catch (InterruptedException e)
            {
                // Mocking TransferQueue::poll(timeout) requires this CheckedException be dealt with
                // If we actually catch one here we've failed at our jobs.
                caught[0] = false;
            }

            assertTrue(Thread.currentThread().isInterrupted());
        });

        t.start();
        t.join();

        assertTrue(caught[0]);
        assertEquals("foo", ie[0].getMessage());
    } 
                            #location 50 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @Test
    public void testInterruptedExceptionDealtWith() throws InterruptedException
    {
        final Throwable[] ex = {null};
        int timeout = 1000;

        Thread testThread = new Thread(() ->
        {
            try
            {
                @SuppressWarnings("unchecked")
                TransferQueue<FakeResponse> fakeQueue =
                        (TransferQueue<FakeResponse>) mock(TransferQueue.class);

                when(fakeQueue.poll(timeout, TimeUnit.MILLISECONDS)).thenThrow(new InterruptedException("foo"));

                @SuppressWarnings("unchecked")
                PBStreamingFutureOperation<FakeResponse, Void, Void> coreFuture =
                        (PBStreamingFutureOperation<FakeResponse, Void, Void>) mock(PBStreamingFutureOperation.class);

                when(coreFuture.getResultsQueue()).thenReturn(fakeQueue);

                // ChunkedResponseIterator polls the response queue when created,
                // so we'll use that to simulate a Thread interrupt.
                new ChunkedResponseIterator<>(coreFuture,
                                              timeout,
                                              Long::new,
                                              FakeResponse::iterator);
            }
            catch (RuntimeException rex)
            {
                ex[0] = rex;
            }
            catch (InterruptedException e)
            {
                // Mocking TransferQueue::poll(timeout) requires this CheckedException be dealt with
                // If we actually catch one here we've failed at our jobs.
                fail(e.getMessage());
            }

            assertTrue(Thread.currentThread().isInterrupted());
        });

        testThread.start();
        testThread.join();

        Throwable caughtException = ex[0];
        assertNotNull(caughtException);

        Throwable wrappedException = caughtException.getCause();
        assertNotNull(caughtException.getMessage(), wrappedException);
        assertEquals("foo", wrappedException.getMessage());
        assertTrue(wrappedException instanceof InterruptedException);
    }