Program: 35327
Project: 35327
Buggy source:
public SearchResult search(SearchRequest searchRequest){
  SearchCacheEntry searchCacheEntry=getSearchCacheEntry(searchRequest);
  SearchResult searchResult=new SearchResult();
  int numberOfWantedResults=searchRequest.getOffset().orElse(0) + searchRequest.getLimit().orElse(100);
  searchResult.setPickingResult(searchCacheEntry.getPickingResult());
  Map<Indexer,List<IndexerSearchResult>> indexersToSearchAndTheirResults=getIndexerSearchResultsToSearch(searchCacheEntry.getIndexerSearchResultsByIndexer());
  int numberOfResultsAlreadyFound=searchResult.calculateNumberOfResults();
  while (indexersToSearchAndTheirResults.size() > 0 && numberOfResultsAlreadyFound < numberOfWantedResults) {
    logger.debug("String_Node_Str",indexersToSearchAndTheirResults.size(),numberOfResultsAlreadyFound,numberOfWantedResults);
    indexersToSearchAndTheirResults=callSearchModules(searchRequest,indexersToSearchAndTheirResults);
    searchCacheEntry.getIndexerSearchResultsByIndexer().putAll(indexersToSearchAndTheirResults);
    searchRequestCache.put(searchRequest.hashCode(),searchCacheEntry);
    searchResult.getIndexerSearchResultMap().putAll(indexersToSearchAndTheirResults);
    List<SearchResultItem> searchResultItems=searchCacheEntry.getIndexerSearchResultsByIndexer().values().stream().flatMap(Collection::stream).filter(IndexerSearchResult::isWasSuccessful).flatMap(x -> x.getSearchResultItems().stream()).collect(Collectors.toList());
    DuplicateDetectionResult duplicateDetectionResult=duplicateDetector.detectDuplicates(searchResultItems);
    createOrUpdateIndexerSearchEntity(searchCacheEntry,indexersToSearchAndTheirResults,duplicateDetectionResult);
    searchResult.setDuplicateDetectionResult(duplicateDetectionResult);
    indexersToSearchAndTheirResults=getIndexerSearchResultsToSearch(indexersToSearchAndTheirResults);
    searchResult.getReasonsForRejection().clear();
    indexersToSearchAndTheirResults.values().forEach(x -> x.forEach(y -> y.getReasonsForRejection().entrySet().forEach(z -> searchResult.getReasonsForRejection().add(z.getElement(),z.getCount()))));
    numberOfResultsAlreadyFound=searchResult.calculateNumberOfResults();
  }
  return searchResult;
}

Fixed version (ground truth):
public SearchResult search(SearchRequest searchRequest){
  SearchCacheEntry searchCacheEntry=getSearchCacheEntry(searchRequest);
  SearchResult searchResult=new SearchResult();
  int numberOfWantedResults=searchRequest.getOffset().orElse(0) + searchRequest.getLimit().orElse(100);
  searchResult.setPickingResult(searchCacheEntry.getPickingResult());
  Map<Indexer,List<IndexerSearchResult>> indexersToSearchAndTheirResults=getIndexerSearchResultsToSearch(searchCacheEntry.getIndexerSearchResultsByIndexer());
  int numberOfResultsAlreadyFound=searchResult.calculateNumberOfResults();
  while (indexersToSearchAndTheirResults.size() > 0 && numberOfResultsAlreadyFound < numberOfWantedResults) {
    logger.debug("String_Node_Str",indexersToSearchAndTheirResults.size(),numberOfResultsAlreadyFound,numberOfWantedResults);
    indexersToSearchAndTheirResults=callSearchModules(searchRequest,indexersToSearchAndTheirResults);
    searchCacheEntry.getIndexerSearchResultsByIndexer().putAll(indexersToSearchAndTheirResults);
    searchRequestCache.put(searchRequest.hashCode(),searchCacheEntry);
    searchResult.getIndexerSearchResultMap().putAll(indexersToSearchAndTheirResults);
    List<SearchResultItem> searchResultItems=searchCacheEntry.getIndexerSearchResultsByIndexer().values().stream().flatMap(Collection::stream).filter(IndexerSearchResult::isWasSuccessful).flatMap(x -> x.getSearchResultItems().stream()).collect(Collectors.toList());
    DuplicateDetectionResult duplicateDetectionResult=duplicateDetector.detectDuplicates(searchResultItems);
    createOrUpdateIndexerSearchEntity(searchCacheEntry,indexersToSearchAndTheirResults,duplicateDetectionResult);
    searchResult.setDuplicateDetectionResult(duplicateDetectionResult);
    indexersToSearchAndTheirResults=getIndexerSearchResultsToSearch(indexersToSearchAndTheirResults);
    searchResult.getReasonsForRejection().clear();
    indexersToSearchAndTheirResults.values().forEach(x -> x.forEach(y -> y.getReasonsForRejection().entrySet().forEach(z -> searchResult.getReasonsForRejection().add(z.getElement(),z.getCount()))));
    numberOfResultsAlreadyFound=searchResult.calculateNumberOfResults();
  }
  searchCacheEntry.setLastSearchResult(searchResult);
  return searchCacheEntry.getLastSearchResult();
}