Buggy code:
public class StorageService implements IEndpointStateChangeSubscriber , StorageServiceMBean { private static Logger logger_ = LoggerFactory . getLogger ( StorageService . class ) ; public static final int RING_DELAY = 30 * 1000 ; public static final String MOVE_STATE = "MOVE" ; public static final char Delimiter = ',' ; public static final String STATE_BOOTSTRAPPING = "BOOT" ; public static final String STATE_NORMAL = "NORMAL" ; public static final String STATE_LEAVING = "LEAVING" ; public static final String STATE_LEFT = "LEFT" ; public static final String REMOVE_TOKEN = "remove" ; public static final String LEFT_NORMALLY = "left" ; public enum Verb { MUTATION , BINARY , READ_REPAIR , READ , READ_RESPONSE , STREAM_INITIATE , STREAM_INITIATE_DONE , STREAM_FINISHED , STREAM_REQUEST , RANGE_SLICE , BOOTSTRAP_TOKEN , TREE_REQUEST , TREE_RESPONSE , GOSSIP_DIGEST_SYN , GOSSIP_DIGEST_ACK , GOSSIP_DIGEST_ACK2 , DEFINITIONS_ANNOUNCE , DEFINITIONS_UPDATE_RESPONSE ; } public static final StorageService . Verb [ ] VERBS = StorageService . Verb . values ( ) ; private static IPartitioner partitioner_ = DatabaseDescriptor . getPartitioner ( ) ; public static final StorageService instance = new StorageService ( ) ; public static IPartitioner getPartitioner ( ) { } public Collection < Range > getLocalRanges ( String table ) { } public Range getLocalPrimaryRange ( ) { } private TokenMetadata tokenMetadata_ = new TokenMetadata ( ) ; private StorageMetadata storageMetadata_ ; private ExecutorService consistencyManager_ = new JMXEnabledThreadPoolExecutor ( DatabaseDescriptor . getConsistencyThreads ( ) , DatabaseDescriptor . getConsistencyThreads ( ) , StageManager . KEEPALIVE , TimeUnit . SECONDS , new LinkedBlockingQueue < Runnable > ( ) , new NamedThreadFactory ( "CONSISTENCY-MANAGER" ) ) ; private Map < String , AbstractReplicationStrategy > replicationStrategies ; private boolean isBootstrapMode ; private Multimap < InetAddress , String > bootstrapSet ; private boolean isClientMode ; private boolean initialized ; private String operationMode ; private MigrationManager migrationManager = new MigrationManager ( ) ; public void addBootstrapSource ( InetAddress s , String table ) { } public void removeBootstrapSource ( InetAddress s , String table ) { } private void finishBootstrapping ( ) { } public void setToken ( Token token ) { } public StorageService ( ) { } public AbstractReplicationStrategy getReplicationStrategy ( String table ) { } public void initReplicationStrategy ( String table ) { } public void clearReplicationStrategy ( String table ) { } public static AbstractReplicationStrategy getReplicationStrategy ( TokenMetadata tokenMetadata , String table ) { } public void stopClient ( ) { } public synchronized void initClient ( ) throws IOException { } public synchronized void initServer ( ) throws IOException { } private void setMode ( String m , boolean log ) { } private void startBootstrap ( Token token ) throws IOException { } public boolean isBootstrapMode ( ) { } public TokenMetadata getTokenMetadata ( ) { } public void doConsistencyCheck ( Row row , List < InetAddress > endpoints , ReadCommand command ) { } public Map < Range , List < String > > getRangeToEndpointMap ( String keyspace ) { } public Map < Range , List < InetAddress > > getRangeToAddressMap ( String keyspace ) { } private Map < Range , List < InetAddress > > constructRangeToEndpointMap ( String keyspace , List < Range > ranges ) { } public void onChange ( InetAddress endpoint , String apStateName , ApplicationState apState ) { } private void handleStateBootstrap ( InetAddress endpoint , String moveValue ) { } private void handleStateNormal ( InetAddress endpoint , String moveValue ) { } private void handleStateLeaving ( InetAddress endpoint , String moveValue ) { } private void handleStateLeft ( InetAddress endpoint , String moveValue ) { } private void removeEndpointLocally ( InetAddress endpoint ) { } private void calculatePendingRanges ( ) { } public static void calculatePendingRanges ( AbstractReplicationStrategy strategy , String table ) { } private void restoreReplicaCount ( InetAddress endpoint ) { } private Multimap < Range , InetAddress > getChangedRangesForLeaving ( String table , InetAddress endpoint ) { } public void onJoin ( InetAddress endpoint , EndpointState epState ) { <START_BUG> for ( Map . Entry < String , ApplicationState > entry : epState . getSortedApplicationStates ( ) ) { <END_BUG> onChange ( endpoint , entry . getKey ( ) , entry . getValue ( ) ) ; } } public void onAlive ( InetAddress endpoint , EndpointState state ) { } public void onDead ( InetAddress endpoint , EndpointState state ) { } public double getLoad ( ) { } public String getLoadString ( ) { } public Map < String , String > getLoadMap ( ) { } public final void deliverHints ( InetAddress endpoint ) { } public Token getLocalToken ( ) { } public String getToken ( ) { } public Set < String > getLiveNodes ( ) { } public Set < String > getUnreachableNodes ( ) { } private Set < String > stringify ( Set < InetAddress > endpoints ) { } private List < String > stringify ( List < InetAddress > endpoints ) { } public int getCurrentGenerationNumber ( ) { } public void forceTableCleanup ( ) throws IOException { } public void forceTableCompaction ( ) throws IOException { } public void takeSnapshot ( String tableName , String tag ) throws IOException { } private Table getValidTable ( String tableName ) throws IOException { } public void takeAllSnapshot ( String tag ) throws IOException { } public void clearSnapshot ( ) throws IOException { } public Iterable < ColumnFamilyStore > getValidColumnFamilies ( String tableName , String ... columnFamilies ) throws IOException { } public void forceTableFlush ( final String tableName , final String ... columnFamilies ) throws IOException { } public void forceTableRepair ( final String tableName , final String ... columnFamilies ) throws IOException { } InetAddress getPredecessor ( InetAddress ep ) { } public InetAddress getSuccessor ( InetAddress ep ) { } public Range getPrimaryRangeForEndpoint ( InetAddress ep ) { } Collection < Range > getRangesForEndpoint ( String table , InetAddress ep ) { } public List < Range > getAllRanges ( List < Token > sortedTokens ) { }

Fix:
for ( Map . Entry < String , ApplicationState > entry : epState . getApplicationStateMap ( ) . entrySet ( ) ) {