Program: 33709
Project: 33709
Buggy source:
@Override protected Void doInBackground(Short... params){
  if (callbacks == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Log.d(Constants.LOG_TAG,"String_Node_Str" + Arrays.deepToString(params));
  Short[] dataToLoad;
  if (params == null) {
    dataToLoad=new Short[]{LaunchActivity.LoadAllDataTaskFragment.LOAD_TEAMS,LaunchActivity.LoadAllDataTaskFragment.LOAD_EVENTS,LaunchActivity.LoadAllDataTaskFragment.LOAD_DISTRICTS};
  }
 else {
    dataToLoad=params;
  }
  Log.d(Constants.LOG_TAG,"String_Node_Str" + Arrays.deepToString(dataToLoad));
  try {
    ArrayList<Team> teams=new ArrayList<>();
    ArrayList<Event> events=new ArrayList<>();
    ArrayList<District> districts=new ArrayList<>();
    int maxPageNum=0;
    if (Arrays.binarySearch(dataToLoad,LaunchActivity.LoadAllDataTaskFragment.LOAD_TEAMS) != -1) {
      for (int pageNum=0; pageNum < 20; pageNum++) {
        if (isCancelled()) {
          return null;
        }
        int start=pageNum * Constants.API_TEAM_LIST_PAGE_SIZE;
        int end=start + Constants.API_TEAM_LIST_PAGE_SIZE - 1;
        start=start == 0 ? 1 : start;
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_teams),start,end)));
        APIResponse<String> teamListResponse;
        teamListResponse=TBAv2.getResponseFromURLOrThrow(context,String.format(TBAv2.getTBAApiUrl(context,TBAv2.QUERY.TEAM_LIST),pageNum),true,false,true);
        JsonArray responseObject=JSONManager.getasJsonArray(teamListResponse.getData());
        if (responseObject != null) {
          if (responseObject.size() == 0) {
            break;
          }
        }
        maxPageNum=Math.max(maxPageNum,pageNum);
        ArrayList<Team> pageTeams=TBAv2.getTeamList(teamListResponse.getData());
        teams.addAll(pageTeams);
      }
    }
    if (Arrays.binarySearch(dataToLoad,LaunchActivity.LoadAllDataTaskFragment.LOAD_EVENTS) != -1) {
      for (int year=Constants.FIRST_COMP_YEAR; year <= Constants.MAX_COMP_YEAR; year++) {
        if (isCancelled()) {
          return null;
        }
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_events),Integer.toString(year))));
        APIResponse<String> eventListResponse;
        String eventsUrl=String.format(TBAv2.getTBAApiUrl(context,TBAv2.QUERY.EVENT_LIST),year);
        eventListResponse=TBAv2.getResponseFromURLOrThrow(context,eventsUrl,true,false,true);
        if (eventListResponse.getCode() == APIResponse.CODE.WEBLOAD || eventListResponse.getCode() == APIResponse.CODE.UPDATED) {
          JsonElement responseObject=JSONManager.getParser().parse(eventListResponse.getData());
          if (responseObject instanceof JsonObject) {
            if (((JsonObject)responseObject).has("String_Node_Str")) {
              continue;
            }
          }
          ArrayList<Event> yearEvents=TBAv2.getEventList(eventListResponse.getData());
          events.addAll(yearEvents);
        }
      }
    }
    if (Arrays.binarySearch(dataToLoad,LaunchActivity.LoadAllDataTaskFragment.LOAD_DISTRICTS) != -1) {
      for (int year=Constants.FIRST_DISTRICT_YEAR; year <= Constants.MAX_COMP_YEAR; year++) {
        if (isCancelled()) {
          return null;
        }
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_districts),year)));
        APIResponse<String> districtListResponse;
        String url=String.format(TBAv2.getTBAApiUrl(context,TBAv2.QUERY.DISTRICT_LIST),year);
        districtListResponse=TBAv2.getResponseFromURLOrThrow(context,url,true,false,true);
        if (districtListResponse.getData() == null) {
          continue;
        }
        JsonElement responseObject=JSONManager.getParser().parse(districtListResponse.getData());
        if (responseObject instanceof JsonObject) {
          if (((JsonObject)responseObject).has("String_Node_Str")) {
            continue;
          }
        }
        ArrayList<District> yearDistricts=TBAv2.getDistrictList(districtListResponse.getData(),url);
        districts.addAll(yearDistricts);
      }
    }
    if (isCancelled()) {
      return null;
    }
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,context.getString(R.string.loading_almost_finished)));
    Log.d(Constants.LOG_TAG,"String_Node_Str");
    Database.getInstance(context).getTeamsTable().storeTeams(teams);
    Log.d(Constants.LOG_TAG,"String_Node_Str");
    Database.getInstance(context).getEventsTable().storeEvents(events);
    Log.d(Constants.LOG_TAG,"String_Node_Str");
    Database.getInstance(context).getDistrictsTable().add(districts);
    SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
    for (int pageNum=0; pageNum <= maxPageNum; pageNum++) {
      editor.putBoolean(DataManager.Teams.ALL_TEAMS_LOADED_TO_DATABASE_FOR_PAGE + pageNum,true);
    }
    for (int year=Constants.FIRST_COMP_YEAR; year <= Constants.MAX_COMP_YEAR; year++) {
      editor.putBoolean(DataManager.Events.ALL_EVENTS_LOADED_TO_DATABASE_FOR_YEAR + year,true);
    }
    for (int year=Constants.FIRST_DISTRICT_YEAR; year <= Constants.MAX_COMP_YEAR; year++) {
      editor.putBoolean(DataManager.Districts.ALL_DISTRICTS_LOADED_TO_DATABASE_FOR_YEAR + year,true);
    }
    editor.putInt(LaunchActivity.APP_VERSION_KEY,BuildConfig.VERSION_CODE);
    editor.apply();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_FINISHED,context.getString(R.string.loading_finished)));
  }
 catch (  DataManager.NoDataException e) {
    e.printStackTrace();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_NO_CONNECTION,context.getString(R.string.connection_lost)));
    Database.getInstance(context).getResponseTable().deleteAllResponses();
  }
catch (  Exception e) {
    e.printStackTrace();
    Database.getInstance(context).getResponseTable().deleteAllResponses();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_ERROR,Utilities.exceptionStacktraceToString(e)));
  }
  return null;
}

Fixed version (ground truth):
@Override protected Void doInBackground(Short... params){
  if (callbacks == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Log.d(Constants.LOG_TAG,"String_Node_Str" + Arrays.deepToString(params));
  Short[] dataToLoad;
  if (params == null) {
    dataToLoad=new Short[]{LaunchActivity.LoadAllDataTaskFragment.LOAD_TEAMS,LaunchActivity.LoadAllDataTaskFragment.LOAD_EVENTS,LaunchActivity.LoadAllDataTaskFragment.LOAD_DISTRICTS};
  }
 else {
    dataToLoad=params;
  }
  Log.d(Constants.LOG_TAG,"String_Node_Str" + Arrays.deepToString(dataToLoad));
  try {
    ArrayList<Team> teams=new ArrayList<>();
    ArrayList<Event> events=new ArrayList<>();
    ArrayList<District> districts=new ArrayList<>();
    int maxPageNum=0;
    if (Arrays.binarySearch(dataToLoad,LaunchActivity.LoadAllDataTaskFragment.LOAD_TEAMS) != -1) {
      for (int pageNum=0; pageNum < 20; pageNum++) {
        if (isCancelled()) {
          return null;
        }
        int start=pageNum * Constants.API_TEAM_LIST_PAGE_SIZE;
        int end=start + Constants.API_TEAM_LIST_PAGE_SIZE - 1;
        start=start == 0 ? 1 : start;
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_teams),start,end)));
        APIResponse<String> teamListResponse;
        teamListResponse=TBAv2.getResponseFromURLOrThrow(context,String.format(TBAv2.getTBAApiUrl(context,TBAv2.QUERY.TEAM_LIST),pageNum),true,false,true);
        JsonArray responseObject=JSONManager.getasJsonArray(teamListResponse.getData());
        if (responseObject != null) {
          if (responseObject.size() == 0) {
            break;
          }
        }
        maxPageNum=Math.max(maxPageNum,pageNum);
        ArrayList<Team> pageTeams=TBAv2.getTeamList(teamListResponse.getData());
        teams.addAll(pageTeams);
      }
    }
    if (Arrays.binarySearch(dataToLoad,LaunchActivity.LoadAllDataTaskFragment.LOAD_EVENTS) != -1) {
      for (int year=Constants.FIRST_COMP_YEAR; year <= Constants.MAX_COMP_YEAR; year++) {
        if (isCancelled()) {
          return null;
        }
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_events),Integer.toString(year))));
        APIResponse<String> eventListResponse;
        String eventsUrl=String.format(TBAv2.getTBAApiUrl(context,TBAv2.QUERY.EVENT_LIST),year);
        eventListResponse=TBAv2.getResponseFromURLOrThrow(context,eventsUrl,true,false,true);
        if (eventListResponse.getCode() == APIResponse.CODE.WEBLOAD || eventListResponse.getCode() == APIResponse.CODE.UPDATED) {
          JsonElement responseObject=JSONManager.getParser().parse(eventListResponse.getData());
          if (responseObject instanceof JsonObject) {
            if (((JsonObject)responseObject).has("String_Node_Str")) {
              continue;
            }
          }
          ArrayList<Event> yearEvents=TBAv2.getEventList(eventListResponse.getData());
          events.addAll(yearEvents);
        }
      }
    }
    if (Arrays.binarySearch(dataToLoad,LaunchActivity.LoadAllDataTaskFragment.LOAD_DISTRICTS) != -1) {
      for (int year=Constants.FIRST_DISTRICT_YEAR; year <= Constants.MAX_COMP_YEAR; year++) {
        if (isCancelled()) {
          return null;
        }
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_districts),year)));
        APIResponse<String> districtListResponse;
        String url=String.format(TBAv2.getTBAApiUrl(context,TBAv2.QUERY.DISTRICT_LIST),year);
        districtListResponse=TBAv2.getResponseFromURLOrThrow(context,url,true,false,true);
        if (districtListResponse.getData() == null) {
          continue;
        }
        JsonElement responseObject=JSONManager.getParser().parse(districtListResponse.getData());
        if (responseObject instanceof JsonObject) {
          if (((JsonObject)responseObject).has("String_Node_Str")) {
            continue;
          }
        }
        ArrayList<District> yearDistricts=TBAv2.getDistrictList(districtListResponse.getData(),url,districtListResponse.getVersion());
        districts.addAll(yearDistricts);
      }
    }
    if (isCancelled()) {
      return null;
    }
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,context.getString(R.string.loading_almost_finished)));
    Log.d(Constants.LOG_TAG,"String_Node_Str");
    Database.getInstance(context).getTeamsTable().storeTeams(teams);
    Log.d(Constants.LOG_TAG,"String_Node_Str");
    Database.getInstance(context).getEventsTable().storeEvents(events);
    Log.d(Constants.LOG_TAG,"String_Node_Str");
    Database.getInstance(context).getDistrictsTable().add(districts);
    SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
    for (int pageNum=0; pageNum <= maxPageNum; pageNum++) {
      editor.putBoolean(DataManager.Teams.ALL_TEAMS_LOADED_TO_DATABASE_FOR_PAGE + pageNum,true);
    }
    for (int year=Constants.FIRST_COMP_YEAR; year <= Constants.MAX_COMP_YEAR; year++) {
      editor.putBoolean(DataManager.Events.ALL_EVENTS_LOADED_TO_DATABASE_FOR_YEAR + year,true);
    }
    for (int year=Constants.FIRST_DISTRICT_YEAR; year <= Constants.MAX_COMP_YEAR; year++) {
      editor.putBoolean(DataManager.Districts.ALL_DISTRICTS_LOADED_TO_DATABASE_FOR_YEAR + year,true);
    }
    editor.putInt(LaunchActivity.APP_VERSION_KEY,BuildConfig.VERSION_CODE);
    editor.apply();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_FINISHED,context.getString(R.string.loading_finished)));
  }
 catch (  DataManager.NoDataException e) {
    e.printStackTrace();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_NO_CONNECTION,context.getString(R.string.connection_lost)));
    Database.getInstance(context).getResponseTable().deleteAllResponses();
  }
catch (  Exception e) {
    e.printStackTrace();
    Database.getInstance(context).getResponseTable().deleteAllResponses();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_ERROR,Utilities.exceptionStacktraceToString(e)));
  }
  return null;
}