Buggy code:
public class StorageProxy implements StorageProxyMBean { private static Logger logger = Logger . getLogger ( StorageProxy . class ) ; private static TimedStatsDeque readStats = new TimedStatsDeque ( 60000 ) ; private static TimedStatsDeque rangeStats = new TimedStatsDeque ( 60000 ) ; private static TimedStatsDeque writeStats = new TimedStatsDeque ( 60000 ) ; private StorageProxy ( ) { } private static Map < EndPoint , Message > createWriteMessages ( RowMutation rm , Map < EndPoint , EndPoint > endpointMap ) throws IOException { } public static void insert ( RowMutation rm ) { } public static void insertBlocking ( RowMutation rm , int consistency_level ) throws UnavailableException { } public static void insertBlocking ( RowMutation rm ) throws UnavailableException { } private static Map < String , Message > constructMessages ( Map < String , ReadCommand > readMessages ) throws IOException { } public static Map < String , Row > doReadProtocol ( Map < String , ReadCommand > readMessages ) throws IOException , TimeoutException { } private static Row weakReadRemote ( ReadCommand command ) throws IOException { } public static Row readProtocol ( ReadCommand command , int consistency_level ) throws IOException , TimeoutException , InvalidRequestException { } public static Map < String , Row > readProtocol ( String [ ] keys , ReadCommand readCommand , StorageService . ConsistencyLevel consistencyLevel ) throws Exception { } public static Map < String , Row > strongReadProtocol ( String [ ] keys , ReadCommand readCommand ) throws IOException , TimeoutException { } private static Row strongRead ( ReadCommand command ) throws IOException , TimeoutException , InvalidRequestException { } private static Map < String , Message [ ] > constructReplicaMessages ( Map < String , ReadCommand [ ] > readMessages ) throws IOException { } private static MultiQuorumResponseHandler dispatchMessages ( Map < String , ReadCommand [ ] > readMessages , Map < String , Message [ ] > messages ) throws IOException { } private static Map < String , Row > doStrongReadProtocol ( Map < String , ReadCommand [ ] > readMessages ) throws IOException { } public static Map < String , Row > weakReadProtocol ( String [ ] keys , ReadCommand readCommand ) throws Exception { } private static Row weakReadLocal ( ReadCommand command ) throws IOException { } static List < String > getKeyRange ( RangeCommand command ) { long startTime = System . currentTimeMillis ( ) ; int endpointOffset = 0 ; List < String > allKeys = new ArrayList < String > ( ) ; int maxResults = command . maxResults ; try { EndPoint endPoint = StorageService . instance ( ) . findSuitableEndPoint ( command . startWith , endpointOffset ) ; String firstEndpoint = endPoint . toString ( ) ; do { IAsyncResult iar = MessagingService . getMessagingInstance ( ) . sendRR ( command . getMessage ( ) , endPoint ) ; byte [ ] responseBody = iar . get ( DatabaseDescriptor . getRpcTimeout ( ) , TimeUnit . MILLISECONDS ) ; RangeReply rangeReply = RangeReply . read ( responseBody ) ; List < String > rangeKeys = rangeReply . keys ; if ( ( ( ( ( allKeys . size ( ) ) > 0 ) && ( rangeKeys != null ) ) && ( ( rangeKeys . size ( ) ) > 0 ) ) && ( allKeys . get ( ( ( allKeys . size ( ) ) - 1 ) ) . equals ( rangeKeys . get ( 0 ) ) ) ) { allKeys . remove ( ( ( allKeys . size ( ) ) - 1 ) ) ; allKeys . addAll ( rangeKeys ) ; } else <START_BUG> if ( ( rangeKeys . size ( ) ) > 0 ) { <END_BUG> allKeys . addAll ( rangeKeys ) ; } if ( ( ( allKeys . size ( ) ) >= maxResults ) || ( rangeReply . rangeCompletedLocally ) ) { break ; } String newStartAt = ( ( allKeys . size ( ) ) > 0 ) ? allKeys . get ( ( ( allKeys . size ( ) ) - 1 ) ) : command . stopAt ; command = new RangeCommand ( command . table , command . columnFamily , newStartAt , command . stopAt , ( ( command . maxResults ) - ( rangeKeys . size ( ) ) ) ) ; endPoint = StorageService . instance ( ) . findSuitableEndPoint ( command . startWith , ( ++ endpointOffset ) ) ; } while ( ! ( endPoint . toString ( ) . equals ( firstEndpoint ) ) ) ; return ( allKeys . size ( ) ) > maxResults ? allKeys . subList ( 0 , maxResults ) : allKeys ; } catch ( Exception e ) { throw new RuntimeException ( ( "error<seq2seq4repair_space>reading<seq2seq4repair_space>keyrange<seq2seq4repair_space>" + command ) , e ) ; } finally { StorageProxy . rangeStats . add ( ( ( System . currentTimeMillis ( ) ) - startTime ) ) ; } } public double getReadLatency ( ) { } public double getRangeLatency ( ) { } public double getWriteLatency ( ) { } public int getReadOperations ( ) { } public int getRangeOperations ( ) { } public int getWriteOperations ( ) { } }

Fix:
if ( ( rangeKeys != null ) && ( ( rangeKeys . size ( ) ) > 0 ) ) {