Program: 159670
Project: 159670
Buggy source:
/** 
 * Get random basic land that can produce specified color mana. Random here means random set and collector id for the same mana producing land.
 * @param color
 * @return
 */
private static Card getBestBasicLand(ColoredManaSymbol color,List<String> setsToUse){
  String cardName="String_Node_Str";
switch (color) {
case G:
    cardName="String_Node_Str";
  break;
case W:
cardName="String_Node_Str";
break;
case R:
cardName="String_Node_Str";
break;
case B:
cardName="String_Node_Str";
break;
case U:
cardName="String_Node_Str";
break;
}
List<String> landSets=new LinkedList<String>();
for (String setCode : setsToUse) {
ExpansionInfo expansionInfo=ExpansionRepository.instance.getSetByCode(setCode);
if (expansionInfo.hasBasicLands()) {
landSets.add(expansionInfo.getCode());
}
}
if (landSets.isEmpty()) {
for (String setCode : setsToUse) {
ExpansionInfo expansionInfo=ExpansionRepository.instance.getSetByCode(setCode);
ExpansionInfo[] blockSets=ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
for (ExpansionInfo blockSet : blockSets) {
if (blockSet.hasBasicLands()) {
landSets.add(blockSet.getCode());
}
}
}
}
if (landSets.isEmpty()) {
Random generator=new Random();
ExpansionInfo[] randomLandSets=ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
if (randomLandSets.length > 0) {
landSets.add(randomLandSets[generator.nextInt(randomLandSets.length) - 1].getCode());
}
}
if (landSets.isEmpty()) {
throw new IllegalArgumentException("String_Node_Str");
}
CardCriteria criteria=new CardCriteria();
if (!landSets.isEmpty()) {
criteria.setCodes(landSets.toArray(new String[landSets.size()]));
}
criteria.rarities(Rarity.LAND).name(cardName);
List<CardInfo> cards=CardRepository.instance.findCards(criteria);
if (cards.isEmpty() && !setsToUse.isEmpty()) {
cards=CardRepository.instance.findCards(cardName);
}
int randomInt=new Random().nextInt(cards.size());
return cards.get(randomInt).getMockCard();
}

Fixed version (ground truth):
/** 
 * Get random basic land that can produce specified color mana. Random here means random set and collector id for the same mana producing land.
 * @param color
 * @return
 */
private static Card getBestBasicLand(ColoredManaSymbol color,List<String> setsToUse){
  String cardName="String_Node_Str";
switch (color) {
case G:
    cardName="String_Node_Str";
  break;
case W:
cardName="String_Node_Str";
break;
case R:
cardName="String_Node_Str";
break;
case B:
cardName="String_Node_Str";
break;
case U:
cardName="String_Node_Str";
break;
}
List<String> landSets=new LinkedList<String>();
for (String setCode : setsToUse) {
ExpansionInfo expansionInfo=ExpansionRepository.instance.getSetByCode(setCode);
if (expansionInfo.hasBasicLands()) {
landSets.add(expansionInfo.getCode());
}
}
if (landSets.isEmpty()) {
for (String setCode : setsToUse) {
ExpansionInfo expansionInfo=ExpansionRepository.instance.getSetByCode(setCode);
ExpansionInfo[] blockSets=ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
for (ExpansionInfo blockSet : blockSets) {
if (blockSet.hasBasicLands()) {
landSets.add(blockSet.getCode());
}
}
}
}
if (landSets.isEmpty()) {
Random generator=new Random();
List<ExpansionInfo> basicLandSets=ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
if (basicLandSets.size() > 0) {
landSets.add(basicLandSets.get(generator.nextInt(basicLandSets.size())).getCode());
}
}
if (landSets.isEmpty()) {
throw new IllegalArgumentException("String_Node_Str");
}
CardCriteria criteria=new CardCriteria();
if (!landSets.isEmpty()) {
criteria.setCodes(landSets.toArray(new String[landSets.size()]));
}
criteria.rarities(Rarity.LAND).name(cardName);
List<CardInfo> cards=CardRepository.instance.findCards(criteria);
if (cards.isEmpty() && !setsToUse.isEmpty()) {
cards=CardRepository.instance.findCards(cardName);
}
int randomInt=new Random().nextInt(cards.size());
return cards.get(randomInt).getMockCard();
}