Buggy code:
public class DataTracker { private static final Logger logger = LoggerFactory . getLogger ( DataTracker . class ) ; public final ColumnFamilyStore cfstore ; private final AtomicReference < DataTracker . View > view ; private final AtomicLong liveSize = new AtomicLong ( ) ; private final AtomicLong totalSize = new AtomicLong ( ) ; public DataTracker ( ColumnFamilyStore cfstore ) { } public Memtable getMemtable ( ) { } public Set < Memtable > getMemtablesPendingFlush ( ) { } public Set < SSTableReader > getSSTables ( ) { } public DataTracker . View getView ( ) { } public Memtable switchMemtable ( ) { } public void renewMemtable ( ) { } public void replaceFlushed ( Memtable memtable , SSTableReader sstable ) { } public void incrementallyBackup ( SSTableReader sstable ) { } public Set < SSTableReader > markCompacting ( Collection < SSTableReader > tomark , int min , int max ) { } public void unmarkCompacting ( Collection < SSTableReader > unmark ) { } public void markCompacted ( Collection < SSTableReader > sstables ) { } public void replaceCompactedSSTables ( Collection < SSTableReader > sstables , Iterable < SSTableReader > replacements ) { } public void addSSTables ( Collection < SSTableReader > sstables ) { } public void addStreamedSSTable ( SSTableReader sstable ) { } public void removeAllSSTables ( ) { } void init ( ) { } private void replace ( Collection < SSTableReader > oldSSTables , Iterable < SSTableReader > replacements ) { } private void addNewSSTablesSize ( Iterable < SSTableReader > newSSTables ) { } private void removeOldSSTablesSize ( Iterable < SSTableReader > oldSSTables ) { } public AutoSavingCache < Pair < Descriptor , DecoratedKey > , Long > getKeyCache ( ) { } public long getLiveSize ( ) { } public long getTotalSize ( ) { } public void spaceReclaimed ( long size ) { } public long estimatedKeys ( ) { } public long [ ] getEstimatedRowSizeHistogram ( ) { } public long [ ] getEstimatedColumnCountHistogram ( ) { } public long getMinRowSize ( ) { } public long getMaxRowSize ( ) { } public long getMeanRowSize ( ) { } public int getMeanColumns ( ) { } public long getBloomFilterFalsePositives ( ) { } public long getRecentBloomFilterFalsePositives ( ) { } public double getBloomFilterFalseRatio ( ) { } public double getRecentBloomFilterFalseRatio ( ) { } static class View { public final Memtable memtable ; public final Set < Memtable > memtablesPendingFlush ; public final Set < SSTableReader > sstables ; public final Set < SSTableReader > compacting ; View ( Memtable memtable , Set < Memtable > pendingFlush , Set < SSTableReader > sstables , Set < SSTableReader > compacting ) { } public DataTracker . View switchMemtable ( Memtable newMemtable ) { <START_BUG> Set < Memtable > newPending = ImmutableSet . < Memtable > builder ( ) . addAll ( memtablesPendingFlush ) . add ( newMemtable ) . build ( ) ; <END_BUG> return new DataTracker . View ( newMemtable , newPending , sstables , compacting ) ; } public DataTracker . View renewMemtable ( Memtable newMemtable ) { } public DataTracker . View replaceFlushed ( Memtable flushedMemtable , SSTableReader newSSTable ) { } public DataTracker . View replace ( Collection < SSTableReader > oldSSTables , Iterable < SSTableReader > replacements ) { } public DataTracker . View markCompacting ( Collection < SSTableReader > tomark ) { } public DataTracker . View unmarkCompacting ( Collection < SSTableReader > tounmark ) { } } }

Fix:
Set < Memtable > newPending = ImmutableSet . < Memtable > builder ( ) . addAll ( memtablesPendingFlush ) . add ( memtable ) . build ( ) ;