Program: 5432
Project: 5432
Buggy source:
private MetadataSearchResponse search(Set<MetadataScope> scopes,String namespaceId,String searchQuery,Set<EntityTypeSimpleName> types,SortInfo sortInfo,int offset,int limit,int numCursors,String cursor,boolean showHidden) throws BadRequestException {
  List<MetadataEntry> results=new ArrayList<>();
  List<String> cursors=new ArrayList<>();
  for (  MetadataScope scope : scopes) {
    SearchResults searchResults=getSearchResults(scope,namespaceId,searchQuery,types,sortInfo,offset,limit,numCursors,cursor,showHidden);
    results.addAll(searchResults.getResults());
    cursors.addAll(searchResults.getCursors());
  }
  Set<NamespacedEntityId> sortedEntities=getSortedEntities(results,sortInfo);
  int startIndex=0;
  int maxEndIndex;
  int total=sortedEntities.size();
  if (SortInfo.DEFAULT.equals(sortInfo)) {
    if (offset > sortedEntities.size()) {
      maxEndIndex=0;
    }
 else {
      startIndex=offset;
      maxEndIndex=(int)Math.min(Integer.MAX_VALUE,(long)offset + limit);
    }
  }
 else {
    maxEndIndex=limit;
    total+=offset;
  }
  sortedEntities=new LinkedHashSet<>(ImmutableList.copyOf(sortedEntities).subList(startIndex,Math.min(maxEndIndex,sortedEntities.size())));
  Map<NamespacedEntityId,Metadata> systemMetadata=fetchMetadata(sortedEntities,MetadataScope.SYSTEM);
  Map<NamespacedEntityId,Metadata> userMetadata=fetchMetadata(sortedEntities,MetadataScope.USER);
  return new MetadataSearchResponse(sortInfo.getSortBy() + "String_Node_Str" + sortInfo.getSortOrder(),offset,limit,numCursors,total,addMetadataToEntities(sortedEntities,systemMetadata,userMetadata),cursors,showHidden);
}

Fixed version (ground truth):
private MetadataSearchResponse search(Set<MetadataScope> scopes,String namespaceId,String searchQuery,Set<EntityTypeSimpleName> types,SortInfo sortInfo,int offset,int limit,int numCursors,String cursor,boolean showHidden) throws BadRequestException {
  if (offset < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (limit < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  List<MetadataEntry> results=new LinkedList<>();
  List<String> cursors=new LinkedList<>();
  List<MetadataEntry> allResults=new LinkedList<>();
  for (  MetadataScope scope : scopes) {
    SearchResults searchResults=getSearchResults(scope,namespaceId,searchQuery,types,sortInfo,offset,limit,numCursors,cursor,showHidden);
    results.addAll(searchResults.getResults());
    cursors.addAll(searchResults.getCursors());
    allResults.addAll(searchResults.getAllResults());
  }
  Set<NamespacedEntityId> sortedEntities=getSortedEntities(results,sortInfo);
  int total=getSortedEntities(allResults,sortInfo).size();
  if (SortInfo.DEFAULT.equals(sortInfo)) {
    int startIndex=Math.min(offset,sortedEntities.size());
    int endIndex=(int)Math.min(Integer.MAX_VALUE,(long)offset + limit);
    endIndex=Math.min(endIndex,sortedEntities.size());
    sortedEntities=new LinkedHashSet<>(ImmutableList.copyOf(sortedEntities).subList(startIndex,endIndex));
  }
  Map<NamespacedEntityId,Metadata> systemMetadata=fetchMetadata(sortedEntities,MetadataScope.SYSTEM);
  Map<NamespacedEntityId,Metadata> userMetadata=fetchMetadata(sortedEntities,MetadataScope.USER);
  return new MetadataSearchResponse(sortInfo.getSortBy() + "String_Node_Str" + sortInfo.getSortOrder(),offset,limit,numCursors,total,addMetadataToEntities(sortedEntities,systemMetadata,userMetadata),cursors,showHidden);
}