Buggy code:
public class OverlayStatsApplication implements TestbedApplication { private static final Logger log = LoggerFactory . getLogger ( OverlayStatsApplication . class ) ; private ScheduledExecutorService scheduler ; public static class MovingAverage { private final Queue < Double > window = new LinkedList < Double > ( ) ; private final int period ; private double sum ; public MovingAverage ( int period ) { } public void newNum ( double num ) { } public double getAvg ( ) { } } private final OverlayStatsApplication . MovingAverage messagesSentMovingAverage10Seconds = new OverlayStatsApplication . MovingAverage ( 10 ) ; private final OverlayStatsApplication . MovingAverage messagesSentMovingAverage60Seconds = new OverlayStatsApplication . MovingAverage ( 60 ) ; private final OverlayStatsApplication . MovingAverage messagesSentMovingAverage300Seconds = new OverlayStatsApplication . MovingAverage ( 300 ) ; private final OverlayStatsApplication . MovingAverage messagesDroppedMovingAverage10Seconds = new OverlayStatsApplication . MovingAverage ( 10 ) ; private final OverlayStatsApplication . MovingAverage messagesDroppedMovingAverage60Seconds = new OverlayStatsApplication . MovingAverage ( 60 ) ; private final OverlayStatsApplication . MovingAverage messagesDroppedMovingAverage300Seconds = new OverlayStatsApplication . MovingAverage ( 300 ) ; private final OverlayStatsApplication . MovingAverage messagesReceivedMovingAverage10Seconds = new OverlayStatsApplication . MovingAverage ( 10 ) ; private final OverlayStatsApplication . MovingAverage messagesReceivedMovingAverage60Seconds = new OverlayStatsApplication . MovingAverage ( 60 ) ; private final OverlayStatsApplication . MovingAverage messagesReceivedMovingAverage300Seconds = new OverlayStatsApplication . MovingAverage ( 300 ) ; private final TestbedRuntime testbedRuntime ; private volatile double messagesSentLastSecond = 0 ; private volatile double messagesDroppedLastSecond = 0 ; private volatile double messagesReceivedLastSecond = 0 ; private ScheduledFuture < ? > calculatingScheduledFuture ; private ScheduledFuture < ? > loggingScheduledFuture ; private MessageEventListener messageEventListener = new MessageEventListener ( ) { @ Override public void messageSent ( Messages . Msg msg ) { } @ Override public void messageDropped ( Messages . Msg msg ) { } @ Override public void messageReceived ( Messages . Msg msg ) { } } ; public OverlayStatsApplication ( TestbedRuntime testbedRuntime , String applicationName , Object configuration ) { } @ Override public String getName ( ) { } @ Override public void start ( ) throws Exception { if ( ( scheduler ) == null ) { <START_BUG> scheduler = Executors . newScheduledThreadPool ( 1 , new ThreadFactoryBuilder ( ) . setNameFormat ( "RuntimeStats-Thread<seq2seq4repair_space>%d" ) . build ( ) ) ; <END_BUG> } testbedRuntime . getMessageEventService ( ) . addListener ( messageEventListener ) ; calculatingScheduledFuture = scheduler . scheduleAtFixedRate ( new Runnable ( ) { @ Override public void run ( ) { double sent = messagesSentLastSecond ; messagesSentLastSecond = 0 ; double dropped = messagesDroppedLastSecond ; messagesDroppedLastSecond = 0 ; double received = messagesReceivedLastSecond ; messagesReceivedLastSecond = 0 ; messagesSentMovingAverage10Seconds . newNum ( sent ) ; messagesSentMovingAverage60Seconds . newNum ( sent ) ; messagesSentMovingAverage300Seconds . newNum ( sent ) ; messagesDroppedMovingAverage10Seconds . newNum ( dropped ) ; messagesDroppedMovingAverage60Seconds . newNum ( dropped ) ; messagesDroppedMovingAverage300Seconds . newNum ( dropped ) ; messagesReceivedMovingAverage10Seconds . newNum ( received ) ; messagesReceivedMovingAverage60Seconds . newNum ( received ) ; messagesReceivedMovingAverage300Seconds . newNum ( received ) ; } } , 1 , 1 , TimeUnit . SECONDS ) ; loggingScheduledFuture = scheduler . scheduleAtFixedRate ( new Runnable ( ) { @ Override public void run ( ) { if ( OverlayStatsApplication . log . isInfoEnabled ( ) ) { DecimalFormat formatter = new DecimalFormat ( "0.00" , new DecimalFormatSymbols ( Locale . ENGLISH ) ) ; OverlayStatsApplication . log . info ( "Overlay<seq2seq4repair_space>messages<seq2seq4repair_space>in<seq2seq4repair_space>[10,60,300]<seq2seq4repair_space>seconds:<seq2seq4repair_space>sent<seq2seq4repair_space>[{},{},{}],<seq2seq4repair_space>received<seq2seq4repair_space>[{},{},{}],<seq2seq4repair_space>dropped<seq2seq4repair_space>[{},{},{}]" , new Object [ ] { formatter . format ( messagesSentMovingAverage10Seconds . getAvg ( ) ) , formatter . format ( messagesSentMovingAverage60Seconds . getAvg ( ) ) , formatter . format ( messagesSentMovingAverage300Seconds . getAvg ( ) ) , formatter . format ( messagesReceivedMovingAverage10Seconds . getAvg ( ) ) , formatter . format ( messagesReceivedMovingAverage60Seconds . getAvg ( ) ) , formatter . format ( messagesReceivedMovingAverage300Seconds . getAvg ( ) ) , formatter . format ( messagesDroppedMovingAverage10Seconds . getAvg ( ) ) , formatter . format ( messagesDroppedMovingAverage60Seconds . getAvg ( ) ) , formatter . format ( messagesDroppedMovingAverage300Seconds . getAvg ( ) ) } ) ; } } } , 10 , 10 , TimeUnit . SECONDS ) ; } @ Override public void stop ( ) throws Exception { } }

Fix:
scheduler = Executors . newScheduledThreadPool ( 1 , new ThreadFactoryBuilder ( ) . setNameFormat ( "OverlayStats-Thread<seq2seq4repair_space>%d" ) . build ( ) ) ;