Program: 39168
Project: 39168
Buggy source:
public void autompleteSearch(final String[] args){
  if ((belongsToFieldDefinition == null || belongsToEntityId != null)) {
    SearchCriteriaBuilder searchCriteriaBuilder=getDataDefinition().find();
    if (StringUtils.hasText(currentCode)) {
      searchCriteriaBuilder.add(SearchRestrictions.like(fieldCode,currentCode,SearchMatchMode.ANYWHERE));
    }
    if (belongsToFieldDefinition != null && belongsToEntityId != null && belongsToFieldDefinition.getType() instanceof BelongsToType) {
      BelongsToType type=(BelongsToType)belongsToFieldDefinition.getType();
      searchCriteriaBuilder.add(SearchRestrictions.belongsTo(belongsToFieldDefinition.getName(),type.getDataDefinition().get(belongsToEntityId)));
    }
    if (getDataDefinition().isActivable()) {
      if (oldSelectedEntityId == null) {
        searchCriteriaBuilder.add(SearchRestrictions.eq("String_Node_Str",true));
      }
 else {
        searchCriteriaBuilder.add(SearchRestrictions.or(SearchRestrictions.eq("String_Node_Str",true),SearchRestrictions.idEq(oldSelectedEntityId)));
      }
    }
    searchCriteriaBuilder.addOrder(SearchOrders.asc(fieldCode));
    SearchResult results=searchCriteriaBuilder.list();
    autocompleteEntitiesNumber=results.getTotalNumberOfEntities();
    if (results.getTotalNumberOfEntities() > 25) {
      autocompleteMatches=new LinkedList<Entity>();
    }
 else {
      autocompleteMatches=results.getEntities();
    }
  }
 else {
    autocompleteMatches=new LinkedList<Entity>();
  }
  autocompleteCode=currentCode;
  requestRender();
}

Fixed version (ground truth):
public void autompleteSearch(final String[] args){
  if ((belongsToFieldDefinition == null || belongsToEntityId != null)) {
    SearchCriteriaBuilder searchCriteriaBuilder=getDataDefinition().find();
    if (StringUtils.hasText(currentCode)) {
      searchCriteriaBuilder.add(SearchRestrictions.like(fieldCode,currentCode,SearchMatchMode.ANYWHERE));
    }
    if (belongsToFieldDefinition != null && belongsToEntityId != null && belongsToFieldDefinition.getType() instanceof BelongsToType) {
      BelongsToType type=(BelongsToType)belongsToFieldDefinition.getType();
      searchCriteriaBuilder.add(SearchRestrictions.belongsTo(belongsToFieldDefinition.getName(),type.getDataDefinition().get(belongsToEntityId)));
    }
    if (getDataDefinition().isActivable()) {
      if (oldSelectedEntityId == null) {
        searchCriteriaBuilder.add(SearchRestrictions.eq("String_Node_Str",true));
      }
 else {
        searchCriteriaBuilder.add(SearchRestrictions.or(SearchRestrictions.eq("String_Node_Str",true),SearchRestrictions.idEq(oldSelectedEntityId)));
      }
    }
    searchCriteriaBuilder.addOrder(SearchOrders.asc(fieldCode));
    if (criteriaModifier != null) {
      criteriaModifier.modifyCriteria(searchCriteriaBuilder);
    }
    SearchResult results=searchCriteriaBuilder.list();
    autocompleteEntitiesNumber=results.getTotalNumberOfEntities();
    if (results.getTotalNumberOfEntities() > 25) {
      autocompleteMatches=new LinkedList<Entity>();
    }
 else {
      autocompleteMatches=results.getEntities();
    }
  }
 else {
    autocompleteMatches=new LinkedList<Entity>();
  }
  autocompleteCode=currentCode;
  requestRender();
}