Program: 97308
Project: 97308
Buggy source:
@Override protected void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException {
  try {
    SearchRequest searchRequest=translationService.convert(request.getInputStream(),CoreTranslatorId.SEARCH_REQUEST);
    SearchOptions options=searchRequest.getOptions();
    TokenOrderType operator=options.isMatchWordOrder() ? TokenOrderType.MATCH_ORDER : TokenOrderType.ANY_ORDER;
    CaseType caseType=options.isCaseSensitive() ? CaseType.MATCH_CASE : CaseType.IGNORE_CASE;
    QueryFactory factory=orcsApi.getQueryFactory(getContext(request));
    QueryBuilder builder=factory.fromBranch(searchRequest.getBranch());
    builder.includeDeleted(options.getDeletionFlag().areDeletedAllowed());
    Collection<IAttributeType> attributeTypes=options.getAttributeTypeFilter();
    if (attributeTypes.isEmpty()) {
      attributeTypes=Collections.singleton(QueryBuilder.ANY_ATTRIBUTE_TYPE);
    }
    builder.and(attributeTypes,searchRequest.getRawSearch(),TokenDelimiterMatch.ANY,operator,caseType);
    BranchCache branchCache=orcsApi.getBranchCache();
    SearchResponse searchResponse=new SearchResponse();
    if (options.isFindAllLocationsEnabled()) {
      ResultSet<Match<ArtifactReadable,AttributeReadable<?>>> results=builder.getMatches();
      for (      Match<ArtifactReadable,AttributeReadable<?>> match : results) {
        ArtifactReadable artifact=match.getItem();
        long branchId=branchCache.getLocalId(artifact.getBranch());
        for (        AttributeReadable<?> attribute : match.getElements()) {
          searchResponse.add(branchId,artifact.getLocalId(),attribute.getGammaId(),match.getLocation(attribute));
        }
      }
    }
 else {
      ResultSet<ArtifactReadable> results=builder.getResults();
      for (      ArtifactReadable artifact : results) {
        long branchId=branchCache.getLocalId(artifact.getBranch());
        searchResponse.add(branchId,artifact.getLocalId(),-1);
      }
    }
    response.setStatus(HttpServletResponse.SC_ACCEPTED);
    response.setContentType("String_Node_Str");
    response.setCharacterEncoding("String_Node_Str");
    InputStream inputStream=translationService.convertToStream(searchResponse,CoreTranslatorId.SEARCH_RESPONSE);
    Lib.inputStreamToOutputStream(inputStream,response.getOutputStream());
  }
 catch (  Exception ex) {
    getLogger().error(ex,"String_Node_Str",request.getRequestURL());
    response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    response.setContentType("String_Node_Str");
    response.getWriter().write(Lib.exceptionToString(ex));
    response.getWriter().flush();
    response.getWriter().close();
  }
}

Fixed version (ground truth):
@Override protected void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException {
  try {
    SearchRequest searchRequest=translationService.convert(request.getInputStream(),CoreTranslatorId.SEARCH_REQUEST);
    SearchOptions options=searchRequest.getOptions();
    TokenOrderType operator=options.isMatchWordOrder() ? TokenOrderType.MATCH_ORDER : TokenOrderType.ANY_ORDER;
    CaseType caseType=options.isCaseSensitive() ? CaseType.MATCH_CASE : CaseType.IGNORE_CASE;
    QueryFactory factory=orcsApi.getQueryFactory(getContext(request));
    QueryBuilder builder=factory.fromBranch(searchRequest.getBranch());
    builder.includeDeletedArtifacts(options.getDeletionFlag().areDeletedAllowed());
    Collection<IAttributeType> attributeTypes=options.getAttributeTypeFilter();
    if (attributeTypes.isEmpty()) {
      attributeTypes=Collections.singleton(QueryBuilder.ANY_ATTRIBUTE_TYPE);
    }
    builder.and(attributeTypes,searchRequest.getRawSearch(),TokenDelimiterMatch.ANY,operator,caseType);
    BranchCache branchCache=orcsApi.getBranchCache();
    SearchResponse searchResponse=new SearchResponse();
    if (options.isFindAllLocationsEnabled()) {
      ResultSet<Match<ArtifactReadable,AttributeReadable<?>>> results=builder.getMatches();
      for (      Match<ArtifactReadable,AttributeReadable<?>> match : results) {
        ArtifactReadable artifact=match.getItem();
        long branchId=branchCache.getLocalId(artifact.getBranch());
        for (        AttributeReadable<?> attribute : match.getElements()) {
          searchResponse.add(branchId,artifact.getLocalId(),attribute.getGammaId(),match.getLocation(attribute));
        }
      }
    }
 else {
      ResultSet<ArtifactReadable> results=builder.getResults();
      for (      ArtifactReadable artifact : results) {
        long branchId=branchCache.getLocalId(artifact.getBranch());
        searchResponse.add(branchId,artifact.getLocalId(),-1);
      }
    }
    response.setStatus(HttpServletResponse.SC_ACCEPTED);
    response.setContentType("String_Node_Str");
    response.setCharacterEncoding("String_Node_Str");
    InputStream inputStream=translationService.convertToStream(searchResponse,CoreTranslatorId.SEARCH_RESPONSE);
    Lib.inputStreamToOutputStream(inputStream,response.getOutputStream());
  }
 catch (  Exception ex) {
    getLogger().error(ex,"String_Node_Str",request.getRequestURL());
    response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    response.setContentType("String_Node_Str");
    response.getWriter().write(Lib.exceptionToString(ex));
    response.getWriter().flush();
    response.getWriter().close();
  }
}