Program: 61481
Project: 61481
Buggy source:
/** 
 * Method that finds all combination of variables mappings Ex: if var 'a' can be mapped to a1 and a2, and var 'b' to b1 and b2, the method return all combinations (a1,b1), (a2,b1), (a1,b2), (a2,b2)
 * @param mappedVars map of variables (out-of-scope) and candidate replacements of
 * @return
 */
public static List<Map<String,CtVariable>> findAllVarMappingCombination(Map<VarAccessWrapper,List<CtVariable>> mappedVars){
  if (mappedVars.isEmpty()) {
    return new ArrayList<Map<String,CtVariable>>();
  }
  List<VarAccessWrapper> varsNamesToCombine=new ArrayList<>(mappedVars.keySet());
  List<Map<String,CtVariable>> allCombinations=new ArrayList<>();
  allCombinations.add(new TreeMap<>());
  int maxNumberCombinations=ConfigurationProperties.getPropertyInt("String_Node_Str");
  int numberTotalComb=1;
  int max=-1;
  for (  VarAccessWrapper currentVar : varsNamesToCombine) {
    List<CtVariable> mapped=mappedVars.get(currentVar);
    int numberCompVar=mapped.size();
    if (numberCompVar > max)     max=numberCompVar;
    logger.debug("String_Node_Str".format("String_Node_Str",currentVar.getVar().getVariable().getSimpleName(),numberCompVar));
    numberTotalComb*=numberCompVar;
  }
  double maxPerVar=Math.pow(numberTotalComb,1.0 / varsNamesToCombine.size());
  double maxPerVarLimit=Math.pow(maxNumberCombinations,1.0 / varsNamesToCombine.size());
  logger.debug("String_Node_Str".format("String_Node_Str",maxPerVar,maxPerVarLimit));
  int partialAnalyzed=0;
  for (  VarAccessWrapper currentVar : varsNamesToCombine) {
    List<Map<String,CtVariable>> generationCombinations=new ArrayList<>();
    List<CtVariable> mapped=mappedVars.get(currentVar);
    for (    CtVariable varFromMap : mapped) {
      int varsAnalyzed=0;
      for (      Map<String,CtVariable> previousCombination : allCombinations) {
        Map<String,CtVariable> newCombination=new TreeMap<>(previousCombination);
        newCombination.put(currentVar.getVar().getVariable().getSimpleName(),varFromMap);
        generationCombinations.add(newCombination);
        varsAnalyzed++;
        if (varsAnalyzed > maxPerVarLimit) {
          break;
        }
      }
    }
    allCombinations=generationCombinations;
  }
  allCombinations=allCombinations.stream().filter(e -> !e.isEmpty()).collect(Collectors.toList());
  logger.debug("String_Node_Str" + allCombinations.size());
  return allCombinations;
}

Fixed version (ground truth):
/** 
 * Method that finds all combination of variables mappings Ex: if var 'a' can be mapped to a1 and a2, and var 'b' to b1 and b2, the method return all combinations (a1,b1), (a2,b1), (a1,b2), (a2,b2)
 * @param mappedVars map of variables (out-of-scope) and candidate replacements of
 * @return
 */
public static List<Map<String,CtVariable>> findAllVarMappingCombination(Map<VarAccessWrapper,List<CtVariable>> mappedVars){
  if (mappedVars.isEmpty()) {
    return new ArrayList<Map<String,CtVariable>>();
  }
  List<VarAccessWrapper> varsNamesToCombine=new ArrayList<>(mappedVars.keySet());
  List<Map<String,CtVariable>> allCombinations=new ArrayList<>();
  allCombinations.add(new TreeMap<>());
  int maxNumberCombinations=ConfigurationProperties.getPropertyInt("String_Node_Str");
  int numberTotalComb=1;
  int max=-1;
  for (  VarAccessWrapper currentVar : varsNamesToCombine) {
    List<CtVariable> mapped=mappedVars.get(currentVar);
    int numberCompVar=mapped.size();
    if (numberCompVar > max)     max=numberCompVar;
    logger.debug(String.format("String_Node_Str",currentVar.getVar().getVariable().getSimpleName(),numberCompVar));
    numberTotalComb*=numberCompVar;
  }
  logger.debug("String_Node_Str" + numberTotalComb);
  double maxPerVar=Math.pow(numberTotalComb,1.0 / varsNamesToCombine.size());
  double maxPerVarLimit=Math.pow(maxNumberCombinations,1.0 / varsNamesToCombine.size());
  logger.debug(String.format("String_Node_Str",maxPerVar,maxPerVarLimit));
  for (  VarAccessWrapper currentVar : varsNamesToCombine) {
    List<Map<String,CtVariable>> generationCombinations=new ArrayList<>();
    List<CtVariable> mapped=mappedVars.get(currentVar);
    List<CtVariable> randomlySortedVariables=new ArrayList<>(mapped);
    Collections.shuffle(randomlySortedVariables,RandomManager.getRandom());
    int varsAnalyzed=0;
    for (    CtVariable varFromMap : mapped) {
      for (      Map<String,CtVariable> previousCombination : allCombinations) {
        Map<String,CtVariable> newCombination=new TreeMap<>(previousCombination);
        newCombination.put(currentVar.getVar().getVariable().getSimpleName(),varFromMap);
        generationCombinations.add(newCombination);
      }
      varsAnalyzed++;
      if (varsAnalyzed > maxPerVarLimit) {
        break;
      }
    }
    allCombinations=generationCombinations;
  }
  allCombinations=allCombinations.stream().filter(e -> !e.isEmpty()).collect(Collectors.toList());
  logger.debug("String_Node_Str" + allCombinations.size());
  return allCombinations;
}