Buggy code:
public class ColumnFamilyStore implements ColumnFamilyStoreMBean { private static Logger logger = LoggerFactory . getLogger ( ColumnFamilyStore . class ) ; private static final ExecutorService flushSorter = new JMXEnabledThreadPoolExecutor ( 1 , Runtime . getRuntime ( ) . availableProcessors ( ) , StageManager . KEEPALIVE , TimeUnit . SECONDS , new LinkedBlockingQueue < Runnable > ( Runtime . getRuntime ( ) . availableProcessors ( ) ) , new NamedThreadFactory ( "FlushSorter" ) , "internal" ) ; private static final ExecutorService flushWriter = new JMXEnabledThreadPoolExecutor ( 1 , DatabaseDescriptor . getFlushWriters ( ) , StageManager . KEEPALIVE , TimeUnit . SECONDS , new SynchronousQueue < Runnable > ( ) , new NamedThreadFactory ( "FlushWriter" ) , "internal" ) ; public static final ExecutorService postFlushExecutor = new JMXEnabledThreadPoolExecutor ( "MemtablePostFlusher" ) ; private Set < Memtable > memtablesPendingFlush = new ConcurrentSkipListSet < Memtable > ( ) ; public final Table table ; public final String columnFamily ; public final IPartitioner partitioner ; private final String mbeanName ; private boolean invalid = false ; private volatile int memtableSwitchCount = 0 ; private AtomicInteger fileIndexGenerator = new AtomicInteger ( 0 ) ; private Memtable memtable ; private final ConcurrentSkipListMap < ByteBuffer , ColumnFamilyStore > indexedColumns ; private AtomicReference < BinaryMemtable > binaryMemtable ; private SSTableTracker ssTables ; private LatencyTracker readStats = new LatencyTracker ( ) ; private LatencyTracker writeStats = new LatencyTracker ( ) ; private final EstimatedHistogram recentSSTablesPerRead = new EstimatedHistogram ( 35 ) ; private final EstimatedHistogram sstablesPerRead = new EstimatedHistogram ( 35 ) ; public final CFMetaData metadata ; private volatile DefaultInteger minCompactionThreshold ; private volatile DefaultInteger maxCompactionThreshold ; private volatile DefaultInteger memtime ; private volatile DefaultInteger memsize ; private volatile DefaultDouble memops ; private volatile DefaultInteger rowCacheSaveInSeconds ; private volatile DefaultInteger keyCacheSaveInSeconds ; private volatile ScheduledFuture < ? > saveRowCacheTask ; private volatile ScheduledFuture < ? > saveKeyCacheTask ; public void reload ( ) { } private ColumnFamilyStore ( Table table , String columnFamilyName , IPartitioner partitioner , int generation , CFMetaData metadata ) { } protected Set < DecoratedKey > readSavedCache ( File path ) { } public void addIndex ( final ColumnDefinition info ) { assert ( info . getIndexType ( ) ) != null ; IPartitioner rowPartitioner = StorageService . getPartitioner ( ) ; AbstractType columnComparator = ( ( rowPartitioner instanceof OrderPreservingPartitioner ) || ( rowPartitioner instanceof ByteOrderedPartitioner ) ) ? BytesType . instance : new org . apache . cassandra . db . marshal . LocalByPartionerType ( StorageService . getPartitioner ( ) ) ; <START_BUG> final CFMetaData indexedCfMetadata = CFMetaData . newIndexMetadata ( table . name , columnFamily , info , columnComparator ) ; <END_BUG> ColumnFamilyStore indexedCfs = ColumnFamilyStore . createColumnFamilyStore ( table , indexedCfMetadata . cfName , new LocalPartitioner ( metadata . getColumn_metadata ( ) . get ( info . name ) . validator ) , indexedCfMetadata ) ; if ( ( indexedColumns . putIfAbsent ( info . name , indexedCfs ) ) != null ) return ; if ( indexedCfs . isIndexBuilt ( ) ) return ; Runnable runnable = new Runnable ( ) { public void run ( ) { try { forceBlockingFlush ( ) ; } catch ( ExecutionException e ) { throw new RuntimeException ( e ) ; } catch ( InterruptedException e ) { throw new AssertionError ( e ) ; } buildSecondaryIndexes ( getSSTables ( ) , FBUtilities . singleton ( info . name ) ) ; SystemTable . setIndexBuilt ( table . name , indexedCfMetadata . cfName ) ; } } ; new Thread ( runnable , ( "Create<seq2seq4repair_space>index<seq2seq4repair_space>" + ( indexedCfMetadata . cfName ) ) ) . start ( ) ; } public void buildSecondaryIndexes ( Collection < SSTableReader > sstables , SortedSet < ByteBuffer > columns ) { } void unregisterMBean ( ) { } public long getMinRowSize ( ) { } public long getMaxRowSize ( ) { } public long getMeanRowSize ( ) { } public int getMeanColumns ( ) { } public static ColumnFamilyStore createColumnFamilyStore ( Table table , String columnFamily ) { } public static synchronized ColumnFamilyStore createColumnFamilyStore ( Table table , String columnFamily , IPartitioner partitioner , CFMetaData metadata ) { } public static void scrubDataDirectories ( String table , String columnFamily ) { } public void initRowCache ( ) { } public void scheduleCacheSaving ( int rowCacheSavePeriodInSeconds , int keyCacheSavePeriodInSeconds ) { } public Future < ? > submitRowCacheWrite ( ) { } public Future < ? > submitKeyCacheWrite ( ) { } private static Map < Descriptor , Set < Component > > files ( String keyspace , final String columnFamily , final boolean includeCompacted ) { } public String getColumnFamilyName ( ) { } public String getFlushPath ( ) { } public String getTempSSTablePath ( String directory ) { } Future < ? > maybeSwitchMemtable ( Memtable oldMemtable , final boolean writeCommitLog ) { } void switchBinaryMemtable ( DecoratedKey key , ByteBuffer buffer ) { } public void forceFlushIfExpired ( ) { } public Future < ? > forceFlush ( ) { } public void forceBlockingFlush ( ) throws InterruptedException , ExecutionException { } public void forceFlushBinary ( ) { } Memtable apply ( DecoratedKey key , ColumnFamily columnFamily ) { } void applyBinary ( DecoratedKey key , ByteBuffer buffer ) { } public static ColumnFamily removeDeletedCF ( ColumnFamily cf , int gcBefore ) { } public static ColumnFamily removeDeleted ( ColumnFamily cf , int gcBefore ) { } private static void removeDeletedColumnsOnly ( ColumnFamily cf , int gcBefore ) { } private static void removeDeletedStandard ( ColumnFamily cf , int gcBefore ) { } private static void removeDeletedSuper ( ColumnFamily cf , int gcBefore ) { } public boolean isKeyInRemainingSSTables ( DecoratedKey key , Set < SSTable > sstablesToIgnore ) { } public void addSSTable ( SSTableReader sstable ) { } long getExpectedCompactedFileSize ( Iterable < SSTableReader > sstables ) { } SSTableReader getMaxSizeFile ( Iterable < SSTableReader > sstables ) { } public void forceCleanup ( ) throws InterruptedException , ExecutionException { }

Fix:
final CFMetaData indexedCfMetadata = CFMetaData . newIndexMetadata ( metadata , info , columnComparator ) ;