Program: 88514
Project: 88514
Buggy source:
public List<?> getEntities(EntityReference ref,Search search){
  log.info(userInfo() + "String_Node_Str");
  Context context;
  try {
    context=new Context();
  }
 catch (  SQLException ex) {
    throw new EntityException("String_Node_Str","String_Node_Str",500);
  }
  UserRequestParams uparams;
  uparams=refreshParams(context);
  List<Object> entities=new ArrayList<Object>();
  try {
    QueryArgs arg=new QueryArgs();
    arg.setQuery(query);
    if (_perpage > 0) {
      arg.setPageSize(_perpage);
    }
    arg.setStart(_start);
    if ((_order.equalsIgnoreCase("String_Node_Str")) || (_order.equalsIgnoreCase("String_Node_Str"))) {
      arg.setSortOrder(SortOption.DESCENDING);
    }
 else {
      arg.setSortOrder(SortOption.ASCENDING);
    }
    QueryResults qre;
    if (_community != null) {
      qre=DSQuery.doQuery(context,arg,_community);
    }
 else     if (_collection != null) {
      qre=DSQuery.doQuery(context,arg,_collection);
    }
 else {
      qre=DSQuery.doQuery(context,arg);
    }
    entities.add(new SearchResultsInfoEntity(qre.getHitCount() - 1,qre.getHitTypes(),qre.getHitHandles(),qre.getHitIds()));
    for (int x=0; x < qre.getHitTypes().size(); x++) {
switch ((Integer)(qre.getHitTypes().get(x))) {
case Constants.ITEM:
{
          entities.add(idOnly ? new ItemEntityId(qre.getHitIds().get(x).toString(),context) : new ItemEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
        }
      break;
case Constants.COMMUNITY:
{
      entities.add(idOnly ? new CommunityEntityId(qre.getHitIds().get(x).toString(),context) : new CommunityEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
    }
  break;
case Constants.COLLECTION:
{
  entities.add(idOnly ? new CollectionEntityId(qre.getHitIds().get(x).toString(),context) : new CollectionEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
}
break;
case Constants.BITSTREAM:
{
entities.add(idOnly ? new BitstreamEntityId(qre.getHitIds().get(x).toString(),context) : new BitstreamEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
}
break;
case Constants.BUNDLE:
{
entities.add(idOnly ? new BundleEntityId(qre.getHitIds().get(x).toString(),context) : new BundleEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
}
break;
case Constants.EPERSON:
{
entities.add(idOnly ? new UserEntityId(qre.getHitIds().get(x).toString(),context) : new UserEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
}
break;
}
}
}
 catch (SQLException sql) {
throw new EntityException("String_Node_Str","String_Node_Str",500);
}
catch (IOException io) {
throw new EntityException("String_Node_Str","String_Node_Str",500);
}
if (!idOnly && sortOptions.size() > 0) {
Collections.sort(entities,new GenComparator(sortOptions));
}
removeTrailing(entities);
return entities;
}

Fixed version (ground truth):
public List<?> getEntities(EntityReference ref,Search search){
  log.info(userInfo() + "String_Node_Str");
  Context context;
  try {
    context=new Context();
  }
 catch (  SQLException ex) {
    throw new EntityException("String_Node_Str","String_Node_Str",500);
  }
  UserRequestParams uparams;
  uparams=refreshParams(context);
  List<Object> entities=new ArrayList<Object>();
  try {
    QueryArgs arg=new QueryArgs();
    arg.setQuery(query);
    if (_perpage > 0) {
      arg.setPageSize(_perpage);
    }
    arg.setStart(_start);
    if ((_order.equalsIgnoreCase("String_Node_Str")) || (_order.equalsIgnoreCase("String_Node_Str"))) {
      arg.setSortOrder(SortOption.DESCENDING);
    }
 else {
      arg.setSortOrder(SortOption.ASCENDING);
    }
    QueryResults qre;
    if (_community != null) {
      qre=DSQuery.doQuery(context,arg,_community);
    }
 else     if (_collection != null) {
      qre=DSQuery.doQuery(context,arg,_collection);
    }
 else {
      qre=DSQuery.doQuery(context,arg);
    }
    entities.add(new SearchResultsInfoEntity(qre.getHitCount(),qre.getHitTypes(),qre.getHitHandles(),qre.getHitIds()));
    for (int x=0; x < qre.getHitTypes().size(); x++) {
switch ((Integer)(qre.getHitTypes().get(x))) {
case Constants.ITEM:
{
          entities.add(idOnly ? new ItemEntityId(qre.getHitIds().get(x).toString(),context) : new ItemEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
        }
      break;
case Constants.COMMUNITY:
{
      entities.add(idOnly ? new CommunityEntityId(qre.getHitIds().get(x).toString(),context) : new CommunityEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
    }
  break;
case Constants.COLLECTION:
{
  entities.add(idOnly ? new CollectionEntityId(qre.getHitIds().get(x).toString(),context) : new CollectionEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
}
break;
case Constants.BITSTREAM:
{
entities.add(idOnly ? new BitstreamEntityId(qre.getHitIds().get(x).toString(),context) : new BitstreamEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
}
break;
case Constants.BUNDLE:
{
entities.add(idOnly ? new BundleEntityId(qre.getHitIds().get(x).toString(),context) : new BundleEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
}
break;
case Constants.EPERSON:
{
entities.add(idOnly ? new UserEntityId(qre.getHitIds().get(x).toString(),context) : new UserEntity(qre.getHitIds().get(x).toString(),context,1,uparams));
}
break;
}
}
context.complete();
}
 catch (SQLException sql) {
throw new EntityException("String_Node_Str","String_Node_Str",500);
}
catch (IOException io) {
throw new EntityException("String_Node_Str","String_Node_Str",500);
}
if (!idOnly && sortOptions.size() > 0) {
Collections.sort(entities,new GenComparator(sortOptions));
}
return entities;
}