private void validateReplicaAvailability(Slice slice,String shard,String collectionName,int count){
  if (slice != null) {
    Collection<Replica> allReplicasForShard=slice.getReplicas();
    if (allReplicasForShard == null) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"No replicas found  in shard/collection: " + shard + "/"+ collectionName);
    }
    if (allReplicasForShard.size() == 1) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"There is only one replica available in shard/collection: " + shard + "/"+ collectionName+ ". Cannot delete that.");
    }
    if (allReplicasForShard.size() <= count) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"There are lesser num replicas requested to be deleted than are available in shard/collection : " + shard + "/"+ collectionName+ " Requested: "+ count+ " Available: "+ allReplicasForShard.size()+ ".");
    }
  }
}

private void validateReplicaAvailability ( Slice slice , String shard , String collectionName , int count ) { if ( slice != null ) { Collection < Replica > allReplicasForShard = slice . getReplicas ( ) ; if ( allReplicasForShard == null ) { throw new SolrException ( SolrException . ErrorCode . BAD_REQUEST , "No replicas found  in shard/collection: " + shard + "/" + collectionName ) ; } if ( allReplicasForShard . size ( ) == 1 ) { throw new SolrException ( SolrException . ErrorCode . BAD_REQUEST , "There is only one replica available in shard/collection: " + shard + "/" + collectionName + ". Cannot delete that." ) ; } if ( allReplicasForShard . size ( ) <= count ) { throw new SolrException ( SolrException . ErrorCode . BAD_REQUEST , "There are lesser num replicas requested to be deleted than are available in shard/collection : " + shard + "/" + collectionName + " Requested: " + count + " Available: " + allReplicasForShard . size ( ) + "." ) ; } } }
validate if there is less replicas than requested to remove . also error out if there is only one replica available
