private void intervalUpdated(Interval aCaller){ if (consumers.size()==0) return; List<IStatsProducer> producers = producerRegistryAPI.getAllProducers(); if (producers.size()==0) return; String intervalName = aCaller.getName(); for (IStatsProducer<?> producer : producers){ ProducerSnapshot snapshot = SnapshotCreator.createSnapshot(producer, intervalName); try{ snapshotQueuedProcessor.addToQueue(snapshot); } catch (UnrecoverableQueueOverflowException e) { log.warn("Queue overflow - throw away snapshot: "+snapshot,e ); } } if (inTestMode){ //if we are in a unittest, we have to wait for producer to empty its queue, because //this producer doesn't support sync mode like queuedeventsender. //Yes, having Thread.sleep() in test is a bad thing to do, but what is the alternative? while(snapshotQueuedProcessor.getQueueSize()!=0){ try{ Thread.sleep(50); }catch(InterruptedException ignored){} } } }