Program: 32153
Project: 32153
Buggy source:
/** 
 * @param response
 * @param responseToMerge
 * @param supportedMediasList
 * @return
 */
private SearchResponse mergeAndFilterResponse(SearchResponse response,SearchResponse responseToMerge,List<String> supportedMediasList){
  SearchRoomEventResults roomEventsToMerge=responseToMerge.searchCategories.roomEvents;
  if (responseToMerge.searchCategories.roomEvents.results.size() > 0) {
    ArrayList<SearchResult> filteredResultList=new ArrayList<SearchResult>();
    for (    SearchResult result : roomEventsToMerge.results) {
      boolean isSupported=false;
      Event event=result.result;
      if (Event.EVENT_TYPE_MESSAGE.equals(event.type)) {
        JsonObject eventContent=event.getContentAsJsonObject();
        String msgType="String_Node_Str";
        JsonElement element=eventContent.get("String_Node_Str");
        if (null != element) {
          msgType=element.getAsString();
        }
        if (!TextUtils.isEmpty(msgType)) {
          isSupported=supportedMediasList.indexOf(msgType) >= 0;
        }
      }
      if (isSupported) {
        filteredResultList.add(result);
      }
      responseToMerge.searchCategories.roomEvents.results=filteredResultList;
    }
    if (null != response) {
      ArrayList<SearchResult> searchResults=new ArrayList<SearchResult>();
      searchResults.addAll(response.searchCategories.roomEvents.results);
      searchResults.addAll(responseToMerge.searchCategories.roomEvents.results);
      responseToMerge.searchCategories.roomEvents.results=searchResults;
      HashMap<String,List<Event>> states=response.searchCategories.roomEvents.state;
      HashMap<String,List<Event>> statesToMerge=responseToMerge.searchCategories.roomEvents.state;
      if ((null != states) && (null != statesToMerge)) {
        for (        String key : states.keySet()) {
          if (!statesToMerge.containsKey(statesToMerge)) {
            statesToMerge.put(key,states.get(key));
          }
        }
      }
 else       if (null == statesToMerge) {
        responseToMerge.searchCategories.roomEvents.state=response.searchCategories.roomEvents.state;
      }
    }
  }
  responseToMerge.searchCategories.roomEvents.count=null;
  responseToMerge.searchCategories.roomEvents.groups=null;
  return responseToMerge;
}

Fixed version (ground truth):
/** 
 * @param response
 * @param responseToMerge
 * @param supportedMediasList
 * @return
 */
private SearchResponse mergeAndFilterResponse(SearchResponse response,SearchResponse responseToMerge,List<String> supportedMediasList){
  SearchRoomEventResults roomEventsToMerge=responseToMerge.searchCategories.roomEvents;
  if (responseToMerge.searchCategories.roomEvents.results.size() > 0) {
    ArrayList<SearchResult> filteredResultList=new ArrayList<SearchResult>();
    for (    SearchResult result : roomEventsToMerge.results) {
      boolean isSupported=false;
      Event event=result.result;
      if (Event.EVENT_TYPE_MESSAGE.equals(event.type)) {
        JsonObject eventContent=event.getContentAsJsonObject();
        String msgType="String_Node_Str";
        JsonElement element=eventContent.get("String_Node_Str");
        if (null != element) {
          msgType=element.getAsString();
        }
        if (!TextUtils.isEmpty(msgType)) {
          isSupported=supportedMediasList.indexOf(msgType) >= 0;
        }
      }
      if (isSupported) {
        filteredResultList.add(result);
      }
      responseToMerge.searchCategories.roomEvents.results=filteredResultList;
    }
    if (null != response) {
      ArrayList<SearchResult> searchResults=new ArrayList<SearchResult>();
      searchResults.addAll(response.searchCategories.roomEvents.results);
      searchResults.addAll(responseToMerge.searchCategories.roomEvents.results);
      responseToMerge.searchCategories.roomEvents.results=searchResults;
      HashMap<String,List<Event>> states=response.searchCategories.roomEvents.state;
      HashMap<String,List<Event>> statesToMerge=responseToMerge.searchCategories.roomEvents.state;
      if ((null != states) && (null != statesToMerge)) {
        for (        String key : states.keySet()) {
          if (!statesToMerge.containsKey(key)) {
            statesToMerge.put(key,states.get(key));
          }
        }
      }
 else       if (null == statesToMerge) {
        responseToMerge.searchCategories.roomEvents.state=response.searchCategories.roomEvents.state;
      }
    }
  }
  responseToMerge.searchCategories.roomEvents.count=null;
  responseToMerge.searchCategories.roomEvents.groups=null;
  return responseToMerge;
}