Program: 61494
Project: 61494
Buggy source:
/** 
 * Return an ingredient. As it has a cache, it never returns twice the same ingredient.
 * @param modificationPoint
 * @param targetStmt
 * @param operationType
 * @param elementsFromFixSpace
 * @return
 */
@Override public Ingredient getFixIngredient(ModificationPoint modificationPoint,AstorOperator operationType){
  int variant_id=modificationPoint.getProgramVariant().getId();
  int attempts=0;
  boolean continueSearching=true;
  int elementsFromFixSpace=getSpaceSize(modificationPoint,operationType);
  Stats.currentStat.initializeIngCounter(variant_id);
  while (continueSearching && attempts < elementsFromFixSpace) {
    Ingredient randomIngredient=super.getFixIngredient(modificationPoint,operationType);
    if (randomIngredient == null || randomIngredient.getCode() == null) {
      return null;
    }
    CtElement elementFromIngredient=randomIngredient.getCode();
    attempts++;
    boolean alreadyApplied=alreadySelected(modificationPoint,elementFromIngredient,operationType);
    if (alreadyApplied) {
      log.debug("String_Node_Str");
      continue;
    }
    boolean sameCode=elementFromIngredient.toString().equals(modificationPoint.getCodeElement().toString());
    if (sameCode) {
      log.debug("String_Node_Str");
      continue;
    }
    boolean transformIngredient=ConfigurationProperties.getPropertyBool("String_Node_Str");
    Stats.currentStat.incrementIngCounter(variant_id);
    if (transformIngredient) {
      if (modificationPoint.getContextOfModificationPoint().isEmpty()) {
        log.debug("String_Node_Str");
      }
      VarMapping mapping=VariableResolver.mapVariables(modificationPoint.getContextOfModificationPoint(),elementFromIngredient);
      if (mapping.getNotMappedVariables().isEmpty()) {
        if (mapping.getMappedVariables().isEmpty()) {
          log.debug("String_Node_Str");
          continueSearching=false;
        }
 else {
          log.debug("String_Node_Str" + elementFromIngredient);
          List<Map<String,CtVariable>> allCombinations=VariableResolver.findAllVarMappingCombination(mapping.getMappedVariables());
          if (allCombinations.size() > 0) {
            Map<String,CtVariable> selectedTransformation=allCombinations.get(0);
            log.debug("String_Node_Str" + selectedTransformation);
            Map<VarAccessWrapper,CtVariableAccess> originalMap=VariableResolver.convertIngredient(mapping,selectedTransformation);
            log.debug("String_Node_Str" + elementFromIngredient);
            boolean fit=VariableResolver.fitInPlace(modificationPoint.getContextOfModificationPoint(),elementFromIngredient);
            continueSearching=!fit;
            log.debug("String_Node_Str" + fit + "String_Node_Str"+ StringUtil.trunc(elementFromIngredient));
          }
        }
      }
 else {
        log.debug("String_Node_Str" + mapping.getNotMappedVariables());
        continue;
      }
    }
    boolean fit=VariableResolver.fitInPlace(modificationPoint.getContextOfModificationPoint(),elementFromIngredient);
    log.debug("String_Node_Str" + fit + "String_Node_Str"+ StringUtil.trunc(elementFromIngredient));
    continueSearching=!fit;
    if (fit) {
      IngredientSpaceScope scope=determineIngredientScope(modificationPoint.getCodeElement(),elementFromIngredient);
      int ingCounter=Stats.currentStat.temporalIngCounterByPatch.get(variant_id);
      log.debug("String_Node_Str" + ingCounter);
      Stats.currentStat.storeSucessfulTransformedIngredient(variant_id,ingCounter);
      return new Ingredient(elementFromIngredient,scope);
    }
  }
  log.debug("String_Node_Str" + StringUtil.trunc(modificationPoint.getCodeElement().getShortRepresentation()) + "String_Node_Str"+ elementsFromFixSpace);
  return null;
}

Fixed version (ground truth):
/** 
 * Return an ingredient. As it has a cache, it never returns twice the same ingredient.
 * @param modificationPoint
 * @param targetStmt
 * @param operationType
 * @param elementsFromFixSpace
 * @return
 */
@Override public Ingredient getFixIngredient(ModificationPoint modificationPoint,AstorOperator operationType){
  int variant_id=modificationPoint.getProgramVariant().getId();
  int attempts=0;
  boolean continueSearching=true;
  int elementsFromFixSpace=getSpaceSize(modificationPoint,operationType);
  Stats.currentStat.initializeIngCounter(variant_id);
  int numberOfIngredientTransformationsDone=0;
  while (continueSearching && attempts < elementsFromFixSpace) {
    Ingredient randomIngredient=super.getFixIngredient(modificationPoint,operationType);
    if (randomIngredient == null || randomIngredient.getCode() == null) {
      return null;
    }
    CtElement elementFromIngredient=randomIngredient.getCode();
    attempts++;
    boolean alreadyApplied=alreadySelected(modificationPoint,elementFromIngredient,operationType);
    if (alreadyApplied) {
      log.debug("String_Node_Str");
      continue;
    }
    boolean sameCode=elementFromIngredient.toString().equals(modificationPoint.getCodeElement().toString());
    if (sameCode) {
      log.debug("String_Node_Str");
      continue;
    }
    boolean transformIngredient=ConfigurationProperties.getPropertyBool("String_Node_Str");
    Stats.currentStat.incrementIngCounter(variant_id);
    if (transformIngredient) {
      if (modificationPoint.getContextOfModificationPoint().isEmpty()) {
        log.debug("String_Node_Str");
      }
      VarMapping mapping=VariableResolver.mapVariables(modificationPoint.getContextOfModificationPoint(),elementFromIngredient);
      if (mapping.getNotMappedVariables().isEmpty()) {
        if (mapping.getMappedVariables().isEmpty()) {
          log.debug("String_Node_Str");
          continueSearching=false;
        }
 else {
          log.debug("String_Node_Str" + elementFromIngredient);
          List<Map<String,CtVariable>> allCombinations=VariableResolver.findAllVarMappingCombination(mapping.getMappedVariables());
          if (allCombinations.size() > 0) {
            numberOfIngredientTransformationsDone++;
            Map<String,CtVariable> selectedTransformation=allCombinations.get(0);
            log.debug("String_Node_Str" + selectedTransformation);
            Map<VarAccessWrapper,CtVariableAccess> originalMap=VariableResolver.convertIngredient(mapping,selectedTransformation);
            log.debug("String_Node_Str" + elementFromIngredient);
            boolean fit=VariableResolver.fitInPlace(modificationPoint.getContextOfModificationPoint(),elementFromIngredient);
            continueSearching=!fit;
            log.debug("String_Node_Str" + fit + "String_Node_Str"+ StringUtil.trunc(elementFromIngredient));
          }
        }
      }
 else {
        log.debug("String_Node_Str" + mapping.getNotMappedVariables());
        continue;
      }
    }
    boolean fit=VariableResolver.fitInPlace(modificationPoint.getContextOfModificationPoint(),elementFromIngredient);
    log.debug("String_Node_Str" + fit + "String_Node_Str"+ StringUtil.trunc(elementFromIngredient));
    continueSearching=!fit;
    if (fit) {
      IngredientSpaceScope scope=determineIngredientScope(modificationPoint.getCodeElement(),elementFromIngredient);
      Stats.currentStat.storeSucessfulTransformedIngredient(variant_id,numberOfIngredientTransformationsDone);
      return new Ingredient(elementFromIngredient,scope);
    }
  }
  log.debug("String_Node_Str" + StringUtil.trunc(modificationPoint.getCodeElement().getShortRepresentation()) + "String_Node_Str"+ elementsFromFixSpace);
  return null;
}