Buggy code:
public static final String CREATE_NODE_SET = "createNodeSet" ; public static final String DELETECOLLECTION = "deletecollection" ; public static final String CREATECOLLECTION = "createcollection" ; public static final String RELOADCOLLECTION = "reloadcollection" ; private static final String QUEUE_OPERATION = "operation" ; private static Logger log = LoggerFactory . getLogger ( OverseerCollectionProcessor . class ) ; private DistributedQueue workQueue ; private String myId ; private ShardHandler shardHandler ; private String adminPath ; private ZkStateReader zkStateReader ; private boolean isClosed ; public OverseerCollectionProcessor ( ZkStateReader zkStateReader , String myId , ShardHandler shardHandler , String adminPath ) { } protected OverseerCollectionProcessor ( ZkStateReader zkStateReader , String myId , ShardHandler shardHandler , String adminPath , DistributedQueue workQueue ) { } @ Override public void run ( ) { } public void close ( ) { } protected boolean amILeader ( ) { } protected boolean processMessage ( ZkNodeProps message , String operation ) { } private boolean createCollection ( ClusterState clusterState , ZkNodeProps message ) { String collectionName = message . getStr ( "name" ) ; if ( clusterState . getCollections ( ) . contains ( collectionName ) ) { SolrException . log ( OverseerCollectionProcessor . log , ( "collection<seq2seq4repair_space>already<seq2seq4repair_space>exists:<seq2seq4repair_space>" + collectionName ) ) ; return false ; } try { int repFactor = msgStrToInt ( message , OverseerCollectionProcessor . REPLICATION_FACTOR , 1 ) ; int numSlices = msgStrToInt ( message , OverseerCollectionProcessor . NUM_SLICES , 0 ) ; int maxShardsPerNode = msgStrToInt ( message , OverseerCollectionProcessor . MAX_SHARDS_PER_NODE , 1 ) ; String createNodeSetStr ; List < String > createNodeList = ( ( createNodeSetStr = message . getStr ( OverseerCollectionProcessor . CREATE_NODE_SET ) ) == null ) ? null : StrUtils . splitSmart ( createNodeSetStr , "," , true ) ; if ( repFactor <= 0 ) { SolrException . log ( OverseerCollectionProcessor . log , ( ( OverseerCollectionProcessor . REPLICATION_FACTOR ) + "<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>><seq2seq4repair_space>0" ) ) ; return false ; } if ( numSlices < 0 ) { SolrException . log ( OverseerCollectionProcessor . log , ( ( OverseerCollectionProcessor . NUM_SLICES ) + "<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>><seq2seq4repair_space>0" ) ) ; return false ; } String configName = message . getStr ( "collection.configName" ) ; Set < String > nodes = clusterState . getLiveNodes ( ) ; List < String > nodeList = new ArrayList < String > ( nodes . size ( ) ) ; nodeList . addAll ( nodes ) ; if ( createNodeList != null ) nodeList . retainAll ( createNodeList ) ; Collections . shuffle ( nodeList ) ; if ( ( nodeList . size ( ) ) <= 0 ) { OverseerCollectionProcessor . log . error ( ( ( ( "Cannot<seq2seq4repair_space>create<seq2seq4repair_space>collection<seq2seq4repair_space>" + collectionName ) + ".<seq2seq4repair_space>No<seq2seq4repair_space>live<seq2seq4repair_space>Solr-instaces" ) + ( createNodeList != null ? "<seq2seq4repair_space>among<seq2seq4repair_space>Solr-instances<seq2seq4repair_space>specified<seq2seq4repair_space>in<seq2seq4repair_space>" + ( OverseerCollectionProcessor . CREATE_NODE_SET ) : "" ) ) ) ; return false ; } if ( repFactor > ( nodeList . size ( ) ) ) { OverseerCollectionProcessor . log . warn ( ( ( ( ( ( ( ( ( "Specified<seq2seq4repair_space>" + ( OverseerCollectionProcessor . REPLICATION_FACTOR ) ) + "<seq2seq4repair_space>of<seq2seq4repair_space>" ) + repFactor ) + "<seq2seq4repair_space>on<seq2seq4repair_space>collection<seq2seq4repair_space>" ) + collectionName ) + "<seq2seq4repair_space>is<seq2seq4repair_space>higher<seq2seq4repair_space>than<seq2seq4repair_space>or<seq2seq4repair_space>equal<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>Solr<seq2seq4repair_space>instances<seq2seq4repair_space>currently<seq2seq4repair_space>live<seq2seq4repair_space>(" ) + ( nodeList . size ( ) ) ) + ").<seq2seq4repair_space>Its<seq2seq4repair_space>unusual<seq2seq4repair_space>to<seq2seq4repair_space>run<seq2seq4repair_space>two<seq2seq4repair_space>replica<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>slice<seq2seq4repair_space>on<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>Solr-instance." ) ) ; } int maxShardsAllowedToCreate = maxShardsPerNode * ( nodeList . size ( ) ) ; int requestedShardsToCreate = numSlices * repFactor ; if ( maxShardsAllowedToCreate < requestedShardsToCreate ) { OverseerCollectionProcessor . log . error ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "Cannot<seq2seq4repair_space>create<seq2seq4repair_space>collection<seq2seq4repair_space>" + collectionName ) + ".<seq2seq4repair_space>Value<seq2seq4repair_space>of<seq2seq4repair_space>" ) + ( OverseerCollectionProcessor . MAX_SHARDS_PER_NODE ) ) + "<seq2seq4repair_space>is<seq2seq4repair_space>" ) + maxShardsPerNode ) + ",<seq2seq4repair_space>and<seq2seq4repair_space>the<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>live<seq2seq4repair_space>nodes<seq2seq4repair_space>is<seq2seq4repair_space>" ) + ( nodeList . size ( ) ) ) + ".<seq2seq4repair_space>This<seq2seq4repair_space>allows<seq2seq4repair_space>a<seq2seq4repair_space>maximum<seq2seq4repair_space>of<seq2seq4repair_space>" ) + maxShardsAllowedToCreate ) + "<seq2seq4repair_space>to<seq2seq4repair_space>be<seq2seq4repair_space>created.<seq2seq4repair_space>Value<seq2seq4repair_space>of<seq2seq4repair_space>" ) + ( OverseerCollectionProcessor . NUM_SLICES ) ) + "<seq2seq4repair_space>is<seq2seq4repair_space>" ) + numSlices ) + "<seq2seq4repair_space>and<seq2seq4repair_space>value<seq2seq4repair_space>of<seq2seq4repair_space>" ) + ( OverseerCollectionProcessor . REPLICATION_FACTOR ) ) + "<seq2seq4repair_space>is<seq2seq4repair_space>" ) + repFactor ) + ".<seq2seq4repair_space>This<seq2seq4repair_space>requires<seq2seq4repair_space>" ) + requestedShardsToCreate ) + "<seq2seq4repair_space>shards<seq2seq4repair_space>to<seq2seq4repair_space>be<seq2seq4repair_space>created<seq2seq4repair_space>(higher<seq2seq4repair_space>than<seq2seq4repair_space>the<seq2seq4repair_space>allowed<seq2seq4repair_space>number)" ) ) ; return false ; } for ( int i = 1 ; i <= numSlices ; i ++ ) { for ( int j = 1 ; j <= repFactor ; j ++ ) { <START_BUG> String nodeName = nodeList . get ( ( ( ( i - 1 ) + ( j - 1 ) ) % ( nodeList . size ( ) ) ) ) ; <END_BUG> String sliceName = "shard" + i ; String shardName = ( ( ( collectionName + "_" ) + sliceName ) + "_replica" ) + j ; OverseerCollectionProcessor . log . info ( ( ( ( ( ( ( ( "Creating<seq2seq4repair_space>shard<seq2seq4repair_space>" + shardName ) + "<seq2seq4repair_space>as<seq2seq4repair_space>part<seq2seq4repair_space>of<seq2seq4repair_space>slice<seq2seq4repair_space>" ) + sliceName ) + "<seq2seq4repair_space>of<seq2seq4repair_space>collection<seq2seq4repair_space>" ) + collectionName ) + "<seq2seq4repair_space>on<seq2seq4repair_space>" ) + nodeName ) ) ; ModifiableSolrParams params = new ModifiableSolrParams ( ) ; params . set ( ACTION , CREATE . toString ( ) ) ; params . set ( NAME , shardName ) ; params . set ( "collection.configName" , configName ) ; params . set ( COLLECTION , collectionName ) ; params . set ( SHARD , sliceName ) ; params . set ( NUM_SHARDS_PROP , numSlices ) ; ShardRequest sreq = new ShardRequest ( ) ; params . set ( "qt" , adminPath ) ; sreq . purpose = 1 ; String replica = zkStateReader . getZkClient ( ) . getBaseUrlForNodeName ( nodeName ) ; if ( replica . startsWith ( "http:////" ) ) replica = replica . substring ( 7 ) ; sreq . shards = new String [ ] { replica } ; sreq . actualShards = sreq . shards ; sreq . params = params ; shardHandler . submit ( sreq , replica , sreq . params ) ; } } int failed = 0 ; ShardResponse srsp ; do { srsp = shardHandler . takeCompletedOrError ( ) ; if ( srsp != null ) { Throwable e = srsp . getException ( ) ;

Fix:
String nodeName = nodeList . get ( ( ( ( repFactor * ( i - 1 ) ) + ( j - 1 ) ) % ( nodeList . size ( ) ) ) ) ;