Program: 113934
Project: 113934
Buggy source:
private List<QBChatDialog> loadAllDialogs(Bundle returnedBundle,QBRequestGetBuilder qbRequestGetBuilder) throws QBResponseException {
  List<QBChatDialog> allDialogsList=null;
  List<QBChatDialog> allDialogsListPrivate=new ArrayList<>();
  List<QBChatDialog> allDialogsListGroup=new ArrayList<>();
  boolean needToLoadMorePrivate=true;
  boolean needToLoadMoreGroup=true;
  int pageNumber=0;
  final QBRequestGetBuilder qbRequestGetBuilderPrivate=new QBRequestGetBuilder();
  qbRequestGetBuilderPrivate.setLimit(ConstsCore.CHATS_DIALOGS_PER_PAGE);
  qbRequestGetBuilderPrivate.sortDesc(QBServiceConsts.EXTRA_LAST_MESSAGE_DATE_SENT);
  qbRequestGetBuilderPrivate.addRule(FIELD_DIALOG_TYPE,OPERATOR_EQ,QBDialogType.PRIVATE.getCode());
  final QBRequestGetBuilder qbRequestGetBuilderGroup=new QBRequestGetBuilder();
  qbRequestGetBuilderGroup.setLimit(ConstsCore.CHATS_DIALOGS_PER_PAGE);
  qbRequestGetBuilderGroup.sortDesc(QBServiceConsts.EXTRA_LAST_MESSAGE_DATE_SENT);
  qbRequestGetBuilderGroup.addRule(FIELD_DIALOG_TYPE,OPERATOR_EQ,QBDialogType.GROUP.getCode());
  do {
    if (needToLoadMorePrivate) {
      needToLoadMorePrivate=loadAllDialogsByType(QBDialogType.PRIVATE,returnedBundle,qbRequestGetBuilderPrivate,allDialogsListPrivate,pageNumber);
    }
    if (needToLoadMoreGroup) {
      needToLoadMoreGroup=loadAllDialogsByType(QBDialogType.GROUP,returnedBundle,qbRequestGetBuilderGroup,allDialogsListGroup,pageNumber);
    }
    List<QBChatDialog> dialogsList=new ArrayList<>(dialogsListPrivate.size() + dialogsListGroup.size());
    dialogsList.addAll(dialogsListPrivate);
    dialogsList.addAll(dialogsListGroup);
    chatHelper.saveDialogsToCache(dialogsList);
    dialogsListPrivate=null;
    dialogsListGroup=null;
    pageNumber++;
    if (pageNumber == FIRST_PAGE_NUMBER) {
      sendLoadPageSuccess(new Bundle());
    }
  }
 while (needToLoadMorePrivate || needToLoadMoreGroup);
  allDialogsList=new ArrayList<>(allDialogsListPrivate.size() + allDialogsListGroup.size());
  allDialogsList.addAll(allDialogsListPrivate);
  allDialogsList.addAll(allDialogsListGroup);
  return allDialogsList;
}

Fixed version (ground truth):
private List<QBChatDialog> loadAllDialogs(Bundle returnedBundle,QBRequestGetBuilder qbRequestGetBuilder) throws QBResponseException {
  List<QBChatDialog> allDialogsList=null;
  List<QBChatDialog> allDialogsListPrivate=new ArrayList<>();
  List<QBChatDialog> allDialogsListGroup=new ArrayList<>();
  boolean needToLoadMorePrivate=true;
  boolean needToLoadMoreGroup=true;
  int pageNumber=0;
  final QBRequestGetBuilder qbRequestGetBuilderPrivate=new QBRequestGetBuilder();
  qbRequestGetBuilderPrivate.setLimit(ConstsCore.CHATS_DIALOGS_PER_PAGE);
  qbRequestGetBuilderPrivate.sortDesc(QBServiceConsts.EXTRA_LAST_MESSAGE_DATE_SENT);
  qbRequestGetBuilderPrivate.addRule(FIELD_DIALOG_TYPE,OPERATOR_EQ,QBDialogType.PRIVATE.getCode());
  final QBRequestGetBuilder qbRequestGetBuilderGroup=new QBRequestGetBuilder();
  qbRequestGetBuilderGroup.setLimit(ConstsCore.CHATS_DIALOGS_PER_PAGE);
  qbRequestGetBuilderGroup.sortDesc(QBServiceConsts.EXTRA_LAST_MESSAGE_DATE_SENT);
  qbRequestGetBuilderGroup.addRule(FIELD_DIALOG_TYPE,OPERATOR_EQ,QBDialogType.GROUP.getCode());
  do {
    if (needToLoadMorePrivate) {
      needToLoadMorePrivate=loadAllDialogsByType(QBDialogType.PRIVATE,returnedBundle,qbRequestGetBuilderPrivate,allDialogsListPrivate,pageNumber);
    }
    if (needToLoadMoreGroup) {
      needToLoadMoreGroup=loadAllDialogsByType(QBDialogType.GROUP,returnedBundle,qbRequestGetBuilderGroup,allDialogsListGroup,pageNumber);
    }
    int sizeListPrivate=dialogsListPrivate == null ? 0 : dialogsListPrivate.size();
    int sizeListGroup=dialogsListGroup == null ? 0 : dialogsListGroup.size();
    List<QBChatDialog> dialogsList=new ArrayList<>(sizeListPrivate + sizeListGroup);
    if (dialogsListPrivate != null)     dialogsList.addAll(dialogsListPrivate);
    if (dialogsListGroup != null)     dialogsList.addAll(dialogsListGroup);
    chatHelper.saveDialogsToCache(dialogsList);
    dialogsListPrivate=null;
    dialogsListGroup=null;
    pageNumber++;
    if (pageNumber == FIRST_PAGE_NUMBER) {
      sendLoadPageSuccess(new Bundle());
    }
  }
 while (needToLoadMorePrivate || needToLoadMoreGroup);
  allDialogsList=new ArrayList<>(allDialogsListPrivate.size() + allDialogsListGroup.size());
  allDialogsList.addAll(allDialogsListPrivate);
  allDialogsList.addAll(allDialogsListGroup);
  return allDialogsList;
}