Buggy code:
public class Monitor implements EventSender { public static final String REPORT_EXCLUSIONS_EXTRA_ACK_CONFIG_PROD = "monitoring.report.exclusions.extra-ack" ; private static final int MAX_CONCURRENCY_DEFAULT = 2 ; private static final long MAX_SIZE_DEFAULT = 1000 ; private static final long MAX_TIME_DEFAULT = 60 ; private static final long PERIODIC_CLEANUP_INTERVAL_MILLIS = TimeUnit . MINUTES . toMillis ( 5 ) ; private static final ScheduledExecutorService scheduler = Executors . newScheduledThreadPool ( 1 ) ; private static final Random randomGenerator = new Random ( ) ; private final EventSender eventSender ; private final Cache < Object , Latencies > latenciesPerId ; private final Logger logger = LoggerFactory . getLogger ( this . getClass ( ) ) ; private final Map < String , String > customAttributes ; private final Object cacheLock ; private final Set < String > extraAckReportingExclusions ; private final String boltService ; private int maxConcurrency ; private long maxSize ; private long maxTime ; public Monitor ( Map conf , final String boltService ) { } private Set < String > getExtraAckReportingExclusions ( Map conf ) { } private Cache < Object , Latencies > createCache ( Map conf , final String boltService ) { } private void initCacheConfig ( Map conf ) { } public Monitor ( ) { } public void startExecute ( Object latencyId , Tuple tuple , String service ) { } public void endExecute ( Object latencyId , Map < String , String > attributes , Throwable er ) { } public void startLatency ( Object latencyId , LatencyType type ) { } public void endLatency ( Object latencyId , LatencyType type ) { } public void send ( RiemannEvent event ) { } private void registerLatency ( Object latencyId , LatencyType type , boolean isStart , String service , Tuple tuple , Map < String , String > attributes , Throwable er ) { final long nanos = System . nanoTime ( ) ; Latencies latencies ; synchronized ( cacheLock ) { switch ( type ) { case EXECUTE : if ( isStart ) { latencies = new Latencies ( nanos , service , tuple ) ; latenciesPerId . put ( latencyId , latencies ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Monitoring<seq2seq4repair_space>latency<seq2seq4repair_space>for<seq2seq4repair_space>key<seq2seq4repair_space>{}" , latencyId ) ; } } else { latencies = latenciesPerId . getIfPresent ( latencyId ) ; if ( ( ( latencies != null ) && ( latencies . setEndNanos ( type , nanos ) ) ) && ( latencies . getLatencyNanos ( type ) . isPresent ( ) ) ) { latenciesPerId . invalidate ( latencyId ) ; long endTimeMillis = System . currentTimeMillis ( ) ; long elapsedMillis = TimeUnit . NANOSECONDS . toMillis ( latencies . getLatencyNanos ( type ) . get ( ) ) ; LatencyEvent event = new LatencyEvent ( elapsedMillis ) . service ( latencies . getService ( ) ) . error ( er ) ; if ( tuple != null ) { event . tuple ( latencies . getTuple ( ) ) ; } if ( attributes != null ) { event . attributes ( attributes ) ; } event . attribute ( "startTime" , Long . toString ( ( endTimeMillis - elapsedMillis ) ) ) ; send ( event ) ; final Optional < Long > emitLatencyNanos = latencies . getLatencyNanos ( EMIT ) ; if ( emitLatencyNanos . isPresent ( ) ) { final long emitMillis = TimeUnit . NANOSECONDS . toMillis ( emitLatencyNanos . get ( ) ) ; if ( emitMillis >= 5 ) { RiemannEvent emitLatencyEvent = new RiemannEvent ( ) . metric ( emitMillis ) . service ( ( service + "<seq2seq4repair_space>emit<seq2seq4repair_space>latency." ) ) . tags ( "emit-latency" ) . service ( this . boltService ) ; if ( tuple != null ) { emitLatencyEvent . tuple ( tuple ) ; } send ( emitLatencyEvent ) ; } } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Monitored<seq2seq4repair_space>latency<seq2seq4repair_space>{}<seq2seq4repair_space>for<seq2seq4repair_space>key<seq2seq4repair_space>{}" , elapsedMillis , latencyId ) ; } } else { if ( ! ( extraAckReportingExclusions . contains ( this . boltService ) ) ) { send ( new ExceptionEvent ( "Latency<seq2seq4repair_space>monitor<seq2seq4repair_space>doesn't<seq2seq4repair_space>recognize<seq2seq4repair_space>key." ) . service ( service ) ) ; if ( er == null ) { logger . warn ( "Latency<seq2seq4repair_space>monitor<seq2seq4repair_space>doesn't<seq2seq4repair_space>recognize<seq2seq4repair_space>key<seq2seq4repair_space>{}." , latencyId ) ; } else { <START_BUG> send ( new ExceptionEvent ( er ) . service ( service ) ) ; <END_BUG> logger . warn ( "Latency<seq2seq4repair_space>monitor<seq2seq4repair_space>doesn't<seq2seq4repair_space>recognize<seq2seq4repair_space>key<seq2seq4repair_space>{}.<seq2seq4repair_space>Swallowed<seq2seq4repair_space>exception<seq2seq4repair_space>{}" , latencyId , er ) ; } } else { logger . trace ( "Excluded<seq2seq4repair_space>event<seq2seq4repair_space>for<seq2seq4repair_space>non<seq2seq4repair_space>recognized<seq2seq4repair_space>key<seq2seq4repair_space>in<seq2seq4repair_space>latency<seq2seq4repair_space>monitor<seq2seq4repair_space>{}." , latencyId ) ; } } } break ; default : latencies = latenciesPerId . getIfPresent ( latencyId ) ; if ( latencies != null ) { if ( isStart ) { latencies . setStartNanos ( type , nanos ) ; } else { latencies . setEndNanos ( type , nanos ) ; } } break ; } } } private Map < String , String > extractCustomEventAttributes ( Map conf ) { } private Map < String , String > parseAttributesString ( String attributesString ) { } public Optional < RiemannEventSender > getRiemannEventSender ( ) { } No newline ; at end ; of file ; }

Fix:
send ( new ExceptionEvent ( er ) . service ( this . boltService ) ) ;