Program: 35332
Project: 35332
Buggy source:
protected SearchCacheEntry getSearchCacheEntry(SearchRequest searchRequest){
  SearchCacheEntry searchCacheEntry;
  Iterator<Map.Entry<Integer,SearchCacheEntry>> iterator=searchRequestCache.entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry<Integer,SearchCacheEntry> next=iterator.next();
    if (next.getValue().getLastAccessed().plus(5,ChronoUnit.MINUTES).isAfter(Instant.now())) {
      searchRequestCache.remove(next.getKey());
    }
  }
  if (searchRequest.getOffset() == 0 || !searchRequestCache.containsKey(searchRequest.hashCode())) {
    SearchEntity searchEntity=new SearchEntity();
    searchEntity.setInternal(searchRequest.isInternal());
    searchEntity.setCategory(searchRequest.getCategory());
    searchEntity.setQuery(searchRequest.getQuery());
    searchEntity.setIdentifiers(searchRequest.getIdentifiers().entrySet().stream().map(x -> new IdentifierKeyValuePair(x.getKey().name(),x.getValue())).collect(Collectors.toList()));
    searchEntity.setSeason(searchRequest.getSeason());
    searchEntity.setEpisode(searchRequest.getEpisode());
    searchEntity.setSearchType(searchRequest.getSearchType());
    searchEntity.setUsername(null);
    searchEntity.setTitle(searchRequest.getTitle());
    searchEntity.setAuthor(searchRequest.getAuthor());
    searchRepository.save(searchEntity);
    List<Indexer> indexersToCall=searchModuleProvider.getIndexers();
    searchCacheEntry=new SearchCacheEntry(searchRequest,indexersToCall);
  }
 else {
    searchCacheEntry=searchRequestCache.get(searchRequest.hashCode());
    searchCacheEntry.setLastAccessed(Instant.now());
    searchCacheEntry.setSearchRequest(searchRequest);
  }
  return searchCacheEntry;
}

Fixed version (ground truth):
protected SearchCacheEntry getSearchCacheEntry(SearchRequest searchRequest){
  SearchCacheEntry searchCacheEntry;
  Iterator<Map.Entry<Integer,SearchCacheEntry>> iterator=searchRequestCache.entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry<Integer,SearchCacheEntry> next=iterator.next();
    if (next.getValue().getLastAccessed().plus(5,ChronoUnit.MINUTES).isBefore(Instant.now())) {
      searchRequestCache.remove(next.getKey());
    }
  }
  if (searchRequest.getOffset().orElse(0) == 0 || !searchRequestCache.containsKey(searchRequest.hashCode())) {
    SearchEntity searchEntity=new SearchEntity();
    searchEntity.setInternal(searchRequest.isInternal());
    searchEntity.setCategory(searchRequest.getCategory());
    searchEntity.setQuery(searchRequest.getQuery().orElse(null));
    searchEntity.setIdentifiers(searchRequest.getIdentifiers().entrySet().stream().map(x -> new IdentifierKeyValuePair(x.getKey().name(),x.getValue())).collect(Collectors.toList()));
    searchEntity.setSeason(searchRequest.getSeason().orElse(null));
    searchEntity.setEpisode(searchRequest.getEpisode().orElse(null));
    searchEntity.setSearchType(searchRequest.getSearchType());
    searchEntity.setUsername(null);
    searchEntity.setTitle(searchRequest.getTitle().orElse(null));
    searchEntity.setAuthor(searchRequest.getAuthor().orElse(null));
    searchRepository.save(searchEntity);
    List<Indexer> indexersToCall=searchModuleProvider.getIndexers();
    searchCacheEntry=new SearchCacheEntry(searchRequest,indexersToCall);
  }
 else {
    searchCacheEntry=searchRequestCache.get(searchRequest.hashCode());
    searchCacheEntry.setLastAccessed(Instant.now());
    searchCacheEntry.setSearchRequest(searchRequest);
  }
  return searchCacheEntry;
}