ProducerListeners listeners() {
        return new ProducerListeners(eventListeners.toArray(new HollowProducerEventListener[0]));
    }
@Test
    public void testAddDuringCycle() {
        ProducerListenerSupport ls = new ProducerListenerSupport();

        class SecondCycleListener implements CycleListener {
            int cycleStart;
            int cycleComplete;

            @Override public void onCycleSkip(CycleSkipReason reason) {
            }

            @Override public void onNewDeltaChain(long version) {
            }

            @Override public void onCycleStart(long version) {
                cycleStart++;
            }

            @Override public void onCycleComplete(Status status, HollowProducer.ReadState rs, long version, Duration elapsed) {
                cycleComplete++;
            }
        }

        class FirstCycleListener extends SecondCycleListener {
            private SecondCycleListener scl = new SecondCycleListener();

            @Override public void onCycleStart(long version) {
                super.onCycleStart(version);
                ls.addListener(scl);
            }
        }

        FirstCycleListener fcl = new FirstCycleListener();
        ls.addListener(fcl);

        ProducerListenerSupport.ProducerListeners s = ls.listeners();
        s.fireCycleStart(1);
        s.fireCycleComplete(new Status.StageWithStateBuilder());

        Assert.assertEquals(1, fcl.cycleStart);
        Assert.assertEquals(1, fcl.cycleComplete);
        Assert.assertEquals(0, fcl.scl.cycleStart);
        Assert.assertEquals(0, fcl.scl.cycleComplete);

        s = ls.listeners();
        s.fireCycleStart(1);
        s.fireCycleComplete(new Status.StageWithStateBuilder());

        Assert.assertEquals(2, fcl.cycleStart);
        Assert.assertEquals(2, fcl.cycleComplete);
        Assert.assertEquals(1, fcl.scl.cycleStart);
        Assert.assertEquals(1, fcl.scl.cycleComplete);
    }