Program: 35295
Project: 35295
Buggy source:
protected String generateQueryIfApplicable(SearchRequest searchRequest,String query) throws IndexerSearchAbortedException {
  if (searchRequest.getQuery().isPresent()) {
    return searchRequest.getQuery().get();
  }
  boolean indexerDoesntSupportRequiredSearchType=config.getSupportedSearchTypes().stream().noneMatch(x -> searchRequest.getSearchType().matches(x));
  boolean indexerDoesntSupportAnyOfTheProvidedIds=searchRequest.getIdentifiers().keySet().stream().noneMatch(x -> config.getSupportedSearchIds().contains(x));
  boolean queryGenerationPossible=!searchRequest.getIdentifiers().isEmpty() || searchRequest.getTitle().isPresent();
  boolean queryGenerationEnabled=configProvider.getBaseConfig().getSearching().getGenerateQueries().meets(searchRequest.getSource()) || searchRequest.getInternalData().getFallbackState() == FallbackState.REQUESTED;
  if (!(queryGenerationPossible && queryGenerationEnabled && (indexerDoesntSupportAnyOfTheProvidedIds || indexerDoesntSupportRequiredSearchType))) {
    logger.debug("String_Node_Str");
    return query;
  }
  if (searchRequest.getInternalData().getFallbackState() == FallbackState.REQUESTED) {
    searchRequest.getInternalData().setFallbackState(FallbackState.USED);
  }
  if (searchRequest.getTitle().isPresent()) {
    query=sanitizeTitleForQuery(searchRequest.getTitle().get());
    logger.debug("String_Node_Str",query);
  }
 else   if (searchRequest.getInternalData().getTitle().isPresent()) {
    query=searchRequest.getInternalData().getTitle().get();
  }
 else {
    Entry<IdType,String> firstIdentifierEntry=searchRequest.getIdentifiers().entrySet().iterator().next();
    try {
      MediaInfo mediaInfo=infoProvider.convert(firstIdentifierEntry.getValue(),firstIdentifierEntry.getKey());
      if (!mediaInfo.getTitle().isPresent()) {
        throw new IndexerSearchAbortedException("String_Node_Str");
      }
      query=sanitizeTitleForQuery(mediaInfo.getTitle().get());
      logger.debug("String_Node_Str",query);
    }
 catch (    InfoProviderException e) {
      throw new IndexerSearchAbortedException("String_Node_Str");
    }
  }
  if (searchRequest.getSeason().isPresent()) {
    if (searchRequest.getEpisode().isPresent()) {
      logger.debug("String_Node_Str",searchRequest.getSeason().get(),searchRequest.getEpisode().get());
      try {
        int episodeInt=Integer.parseInt(searchRequest.getEpisode().get());
        query+=String.format("String_Node_Str",searchRequest.getSeason().get(),episodeInt);
      }
 catch (      NumberFormatException e) {
        String extendWith=String.format("String_Node_Str",searchRequest.getSeason().get()) + searchRequest.getEpisode().get();
        query+=extendWith;
        logger.debug("String_Node_Str",searchRequest.getEpisode().get(),extendWith);
      }
    }
 else {
      logger.debug("String_Node_Str",searchRequest.getSeason().get());
      query+=String.format("String_Node_Str",searchRequest.getSeason().get());
    }
  }
  if (searchRequest.getSearchType() == SearchType.BOOK && !config.getSupportedSearchTypes().contains(ActionAttribute.BOOK)) {
    if (searchRequest.getAuthor().isPresent()) {
      query+="String_Node_Str" + searchRequest.getAuthor().get();
      logger.debug("String_Node_Str",searchRequest.getAuthor().get());
    }
  }
  info("String_Node_Str" + query);
  return query;
}

Fixed version (ground truth):
protected String generateQueryIfApplicable(SearchRequest searchRequest,String query) throws IndexerSearchAbortedException {
  if (searchRequest.getQuery().isPresent()) {
    return searchRequest.getQuery().get();
  }
  boolean indexerDoesntSupportRequiredSearchType=config.getSupportedSearchTypes().stream().noneMatch(x -> searchRequest.getSearchType().matches(x));
  boolean indexerDoesntSupportAnyOfTheProvidedIds=searchRequest.getIdentifiers().keySet().stream().noneMatch(x -> config.getSupportedSearchIds().contains(x));
  boolean queryGenerationPossible=!searchRequest.getIdentifiers().isEmpty() || searchRequest.getTitle().isPresent();
  boolean queryGenerationEnabled=configProvider.getBaseConfig().getSearching().getGenerateQueries().meets(searchRequest.getSource()) || searchRequest.getInternalData().getFallbackState() == FallbackState.REQUESTED;
  if (!(queryGenerationPossible && queryGenerationEnabled && (indexerDoesntSupportAnyOfTheProvidedIds || indexerDoesntSupportRequiredSearchType))) {
    debug("String_Node_Str");
    return query;
  }
  if (searchRequest.getInternalData().getFallbackState() == FallbackState.REQUESTED) {
    searchRequest.getInternalData().setFallbackState(FallbackState.USED);
  }
  if (searchRequest.getTitle().isPresent()) {
    query=sanitizeTitleForQuery(searchRequest.getTitle().get());
    debug("String_Node_Str",query);
  }
 else   if (searchRequest.getInternalData().getTitle().isPresent()) {
    query=searchRequest.getInternalData().getTitle().get();
  }
 else {
    Entry<IdType,String> firstIdentifierEntry=searchRequest.getIdentifiers().entrySet().iterator().next();
    try {
      MediaInfo mediaInfo=infoProvider.convert(firstIdentifierEntry.getValue(),firstIdentifierEntry.getKey());
      if (!mediaInfo.getTitle().isPresent()) {
        throw new IndexerSearchAbortedException("String_Node_Str");
      }
      query=sanitizeTitleForQuery(mediaInfo.getTitle().get());
      debug("String_Node_Str",query);
    }
 catch (    InfoProviderException e) {
      throw new IndexerSearchAbortedException("String_Node_Str");
    }
  }
  if (searchRequest.getSeason().isPresent()) {
    if (searchRequest.getEpisode().isPresent()) {
      debug("String_Node_Str",searchRequest.getSeason().get(),searchRequest.getEpisode().get());
      try {
        int episodeInt=Integer.parseInt(searchRequest.getEpisode().get());
        query+=String.format("String_Node_Str",searchRequest.getSeason().get(),episodeInt);
      }
 catch (      NumberFormatException e) {
        String extendWith=String.format("String_Node_Str",searchRequest.getSeason().get()) + searchRequest.getEpisode().get();
        query+=extendWith;
        debug("String_Node_Str",searchRequest.getEpisode().get(),extendWith);
      }
    }
 else {
      debug("String_Node_Str",searchRequest.getSeason().get());
      query+=String.format("String_Node_Str",searchRequest.getSeason().get());
    }
  }
  if (searchRequest.getSearchType() == SearchType.BOOK && !config.getSupportedSearchTypes().contains(ActionAttribute.BOOK)) {
    if (searchRequest.getAuthor().isPresent()) {
      query+="String_Node_Str" + searchRequest.getAuthor().get();
      debug("String_Node_Str",searchRequest.getAuthor().get());
    }
  }
  debug("String_Node_Str" + query);
  return query;
}