Buggy code:
public class GCInspector { private static final Logger logger = LoggerFactory . getLogger ( GCInspector . class ) ; static final long INTERVAL_IN_MS = 1000 ; static final long MIN_DURATION = 200 ; static final long MIN_DURATION_TPSTATS = 1000 ; public static final GCInspector instance = new GCInspector ( ) ; private HashMap < String , Long > gctimes = new HashMap < String , Long > ( ) ; private HashMap < String , Long > gccounts = new HashMap < String , Long > ( ) ; List < GarbageCollectorMXBean > beans = new ArrayList < GarbageCollectorMXBean > ( ) ; MemoryMXBean membean = ManagementFactory . getMemoryMXBean ( ) ; private volatile boolean cacheSizesReduced ; public GCInspector ( ) { } public void start ( ) { } private void logGCResults ( ) { for ( GarbageCollectorMXBean gc : beans ) { Long previousTotal = gctimes . get ( gc . getName ( ) ) ; Long total = gc . getCollectionTime ( ) ; if ( previousTotal == null ) previousTotal = 0L ; if ( previousTotal . equals ( total ) ) continue ; gctimes . put ( gc . getName ( ) , total ) ; Long duration = total - previousTotal ; assert duration > 0 ; Long previousCount = gccounts . get ( gc . getName ( ) ) ; Long count = gc . getCollectionCount ( ) ; if ( previousCount == null ) previousCount = 0L ; <START_BUG> if ( count == previousCount ) <END_BUG> continue ; gccounts . put ( gc . getName ( ) , count ) ; MemoryUsage mu = membean . getHeapMemoryUsage ( ) ; long memoryUsed = mu . getUsed ( ) ; long memoryMax = mu . getMax ( ) ; String st = String . format ( "GC<seq2seq4repair_space>for<seq2seq4repair_space>%s:<seq2seq4repair_space>%s<seq2seq4repair_space>ms<seq2seq4repair_space>for<seq2seq4repair_space>%s<seq2seq4repair_space>collections,<seq2seq4repair_space>%s<seq2seq4repair_space>used;<seq2seq4repair_space>max<seq2seq4repair_space>is<seq2seq4repair_space>%s" , gc . getName ( ) , duration , ( count - previousCount ) , memoryUsed , memoryMax ) ; long durationPerCollection = duration // ( count - previousCount ) ; if ( durationPerCollection > ( GCInspector . MIN_DURATION ) ) GCInspector . logger . info ( st ) ; else if ( GCInspector . logger . isDebugEnabled ( ) ) GCInspector . logger . debug ( st ) ; if ( durationPerCollection > ( GCInspector . MIN_DURATION_TPSTATS ) ) StatusLogger . log ( ) ; if ( gc . getName ( ) . equals ( "ConcurrentMarkSweep" ) ) { double usage = ( ( double ) ( memoryUsed ) ) // memoryMax ; if ( ( memoryUsed > ( ( DatabaseDescriptor . getReduceCacheSizesAt ( ) ) * memoryMax ) ) && ( ! ( cacheSizesReduced ) ) ) { cacheSizesReduced = true ; GCInspector . logger . warn ( ( ( "Heap<seq2seq4repair_space>is<seq2seq4repair_space>" + usage ) + "<seq2seq4repair_space>full.<seq2seq4repair_space>You<seq2seq4repair_space>may<seq2seq4repair_space>need<seq2seq4repair_space>to<seq2seq4repair_space>reduce<seq2seq4repair_space>memtable<seq2seq4repair_space>and//or<seq2seq4repair_space>cache<seq2seq4repair_space>sizes.<seq2seq4repair_space>Cassandra<seq2seq4repair_space>is<seq2seq4repair_space>now<seq2seq4repair_space>reducing<seq2seq4repair_space>cache<seq2seq4repair_space>sizes<seq2seq4repair_space>to<seq2seq4repair_space>free<seq2seq4repair_space>up<seq2seq4repair_space>memory.<seq2seq4repair_space>Adjust<seq2seq4repair_space>reduce_cache_sizes_at<seq2seq4repair_space>threshold<seq2seq4repair_space>in<seq2seq4repair_space>cassandra.yaml<seq2seq4repair_space>if<seq2seq4repair_space>you<seq2seq4repair_space>don't<seq2seq4repair_space>want<seq2seq4repair_space>Cassandra<seq2seq4repair_space>to<seq2seq4repair_space>do<seq2seq4repair_space>this<seq2seq4repair_space>automatically" ) ) ; StorageService . instance . reduceCacheSizes ( ) ; } if ( memoryUsed > ( ( DatabaseDescriptor . getFlushLargestMemtablesAt ( ) ) * memoryMax ) ) { GCInspector . logger . warn ( ( ( "Heap<seq2seq4repair_space>is<seq2seq4repair_space>" + usage ) + "<seq2seq4repair_space>full.<seq2seq4repair_space>You<seq2seq4repair_space>may<seq2seq4repair_space>need<seq2seq4repair_space>to<seq2seq4repair_space>reduce<seq2seq4repair_space>memtable<seq2seq4repair_space>and//or<seq2seq4repair_space>cache<seq2seq4repair_space>sizes.<seq2seq4repair_space>Cassandra<seq2seq4repair_space>will<seq2seq4repair_space>now<seq2seq4repair_space>flush<seq2seq4repair_space>up<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>two<seq2seq4repair_space>largest<seq2seq4repair_space>memtables<seq2seq4repair_space>to<seq2seq4repair_space>free<seq2seq4repair_space>up<seq2seq4repair_space>memory.<seq2seq4repair_space>Adjust<seq2seq4repair_space>flush_largest_memtables_at<seq2seq4repair_space>threshold<seq2seq4repair_space>in<seq2seq4repair_space>cassandra.yaml<seq2seq4repair_space>if<seq2seq4repair_space>you<seq2seq4repair_space>don't<seq2seq4repair_space>want<seq2seq4repair_space>Cassandra<seq2seq4repair_space>to<seq2seq4repair_space>do<seq2seq4repair_space>this<seq2seq4repair_space>automatically" ) ) ; StorageService . instance . flushLargestMemtables ( ) ; } } } } }

Fix:
if ( count . equals ( previousCount ) )