private void doWork(final IdleStrategy idleStrategy, final Agent agent)
    {
        try
        {
            final int workCount = agent.doWork();
            idleStrategy.idle(workCount);
            if (workCount <= 0 && Thread.currentThread().isInterrupted())
            {
                isRunning = false;
            }
        }
        catch (final InterruptedException | ClosedByInterruptException ignore)
        {
            isRunning = false;
            Thread.currentThread().interrupt();
        }
        catch (final AgentTerminationException ex)
        {
            isRunning = false;
            handleError(ex);
        }
        catch (final Throwable t)
        {
            if (Thread.currentThread().isInterrupted())
            {
                isRunning = false;
            }

            handleError(t);
            if (isRunning && Thread.currentThread().isInterrupted())
            {
                isRunning = false;
            }

            if (t instanceof Error)
            {
                throw (Error)t;
            }
        }
    }
@Test
    void shouldNotReportClosedByInterruptException() throws Exception
    {
        when(mockAgent.doWork()).thenThrow(new ClosedByInterruptException());

        assertExceptionNotReported();
    }