Program: 33589
Project: 33589
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[]{LOAD_TEAMS,LOAD_EVENTS,LOAD_DISTRICTS};
  }
 else {
    dataToLoad=params;
  }
  Log.d(Constants.LOG_TAG,"String_Node_Str" + Arrays.deepToString(dataToLoad));
  try {
    Call<APIStatus> statusCall=datafeed.statusCall();
    Response<APIStatus> statusResponse=statusCall.execute();
    if (!statusResponse.isSuccess() && statusResponse.body() != null) {
      onConnectionError();
      return null;
    }
    int maxCompYear=statusResponse.body().getMaxSeason();
    List<Team> allTeams=new ArrayList<>();
    int maxPageNum=0;
    if (Arrays.binarySearch(dataToLoad,LOAD_TEAMS) != -1) {
      mDb.getTeamsTable().deleteAllRows();
      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)));
        Call<List<Team>> teamListCall=datafeed.fetchTeamPageCall(pageNum,APIv2.TBA_CACHE_WEB);
        Response<List<Team>> teamListResponse=teamListCall.execute();
        if (teamListResponse == null || !teamListResponse.isSuccess() || teamListResponse.body() == null) {
          onConnectionError();
          return null;
        }
        if (teamListResponse.body().isEmpty()) {
          break;
        }
        allTeams.addAll(teamListResponse.body());
        maxPageNum=Math.max(maxPageNum,pageNum);
      }
    }
    List<Event> allEvents=new ArrayList<>();
    if (Arrays.binarySearch(dataToLoad,LOAD_EVENTS) != -1) {
      mDb.getEventsTable().deleteAllRows();
      for (int year=Constants.FIRST_COMP_YEAR; year <= maxCompYear; year++) {
        if (isCancelled()) {
          return null;
        }
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_events),Integer.toString(year))));
        Call<List<Event>> eventListCall=datafeed.fetchEventsInYearCall(year,APIv2.TBA_CACHE_WEB);
        Response<List<Event>> eventListResponse=eventListCall.execute();
        if (eventListResponse == null || !eventListResponse.isSuccess() || eventListResponse.body() == null) {
          onConnectionError();
          return null;
        }
        allEvents.addAll(eventListResponse.body());
        Log.i(Constants.LOG_TAG,String.format("String_Node_Str",eventListResponse.body().size(),year));
      }
    }
    List<District> allDistricts=new ArrayList<>();
    if (Arrays.binarySearch(dataToLoad,LOAD_DISTRICTS) != -1) {
      mDb.getDistrictsTable().deleteAllRows();
      for (int year=Constants.FIRST_DISTRICT_YEAR; year <= maxCompYear; year++) {
        if (isCancelled()) {
          return null;
        }
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_districts),year)));
        AddDistrictKeys keyAdder=new AddDistrictKeys(year);
        Call<List<District>> districtListCall=datafeed.fetchDistrictListCall(year,APIv2.TBA_CACHE_WEB);
        Response<List<District>> districtListResponse=districtListCall.execute();
        if (districtListResponse == null || !districtListResponse.isSuccess() || districtListResponse.body() == null) {
          onConnectionError();
          return null;
        }
        List<District> newDistrictList=districtListResponse.body();
        keyAdder.call(newDistrictList);
        allDistricts.addAll(newDistrictList);
        Log.i(Constants.LOG_TAG,String.format("String_Node_Str",newDistrictList.size(),year));
      }
    }
    if (isCancelled()) {
      return null;
    }
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,context.getString(R.string.loading_almost_finished)));
    Log.i(Constants.LOG_TAG,"String_Node_Str" + allTeams.size() + "String_Node_Str");
    Schedulers.io().createWorker().schedule(() -> mTeamWriter.write(allTeams));
    Log.i(Constants.LOG_TAG,"String_Node_Str" + allEvents.size() + "String_Node_Str");
    Schedulers.io().createWorker().schedule(() -> mEventWriter.write(allEvents));
    Log.i(Constants.LOG_TAG,"String_Node_Str" + allDistricts.size() + "String_Node_Str");
    Schedulers.io().createWorker().schedule(() -> mDistrictWriter.write(allDistricts));
    SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
    editor.putString(TBAStatusController.STATUS_PREF_KEY,statusResponse.body().getJsonBlob());
    editor.putInt(Constants.LAST_YEAR_KEY,statusResponse.body().getMaxSeason());
    for (int pageNum=0; pageNum <= maxPageNum; pageNum++) {
      editor.putBoolean(Database.ALL_TEAMS_LOADED_TO_DATABASE_FOR_PAGE + pageNum,true);
    }
    for (int year=Constants.FIRST_COMP_YEAR; year <= maxCompYear; year++) {
      editor.putBoolean(Database.ALL_EVENTS_LOADED_TO_DATABASE_FOR_YEAR + year,true);
    }
    for (int year=Constants.FIRST_DISTRICT_YEAR; year <= maxCompYear; year++) {
      editor.putBoolean(Database.ALL_DISTRICTS_LOADED_TO_DATABASE_FOR_YEAR + year,true);
    }
    editor.putInt(Constants.APP_VERSION_KEY,BuildConfig.VERSION_CODE);
    editor.apply();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_FINISHED,context.getString(R.string.loading_finished)));
  }
 catch (  RuntimeException ex) {
    ex.printStackTrace();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_ERROR,Utilities.exceptionStacktraceToString(ex)));
  }
catch (  IOException e) {
    e.printStackTrace();
    onConnectionError();
  }
  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[]{LOAD_TEAMS,LOAD_EVENTS,LOAD_DISTRICTS};
  }
 else {
    dataToLoad=params;
  }
  Log.d(Constants.LOG_TAG,"String_Node_Str" + Arrays.deepToString(dataToLoad));
  try {
    Call<APIStatus> statusCall=datafeed.statusCall();
    Response<APIStatus> statusResponse=statusCall.execute();
    if (!statusResponse.isSuccess() || statusResponse.body() == null) {
      onConnectionError();
      return null;
    }
    int maxCompYear=statusResponse.body().getMaxSeason();
    List<Team> allTeams=new ArrayList<>();
    int maxPageNum=0;
    if (Arrays.binarySearch(dataToLoad,LOAD_TEAMS) != -1) {
      mDb.getTeamsTable().deleteAllRows();
      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)));
        Call<List<Team>> teamListCall=datafeed.fetchTeamPageCall(pageNum,APIv2.TBA_CACHE_WEB);
        Response<List<Team>> teamListResponse=teamListCall.execute();
        if (teamListResponse == null || !teamListResponse.isSuccess() || teamListResponse.body() == null) {
          onConnectionError();
          return null;
        }
        if (teamListResponse.body().isEmpty()) {
          break;
        }
        allTeams.addAll(teamListResponse.body());
        maxPageNum=Math.max(maxPageNum,pageNum);
      }
    }
    List<Event> allEvents=new ArrayList<>();
    if (Arrays.binarySearch(dataToLoad,LOAD_EVENTS) != -1) {
      mDb.getEventsTable().deleteAllRows();
      for (int year=Constants.FIRST_COMP_YEAR; year <= maxCompYear; year++) {
        if (isCancelled()) {
          return null;
        }
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_events),Integer.toString(year))));
        Call<List<Event>> eventListCall=datafeed.fetchEventsInYearCall(year,APIv2.TBA_CACHE_WEB);
        Response<List<Event>> eventListResponse=eventListCall.execute();
        if (eventListResponse == null || !eventListResponse.isSuccess() || eventListResponse.body() == null) {
          onConnectionError();
          return null;
        }
        allEvents.addAll(eventListResponse.body());
        Log.i(Constants.LOG_TAG,String.format("String_Node_Str",eventListResponse.body().size(),year));
      }
    }
    List<District> allDistricts=new ArrayList<>();
    if (Arrays.binarySearch(dataToLoad,LOAD_DISTRICTS) != -1) {
      mDb.getDistrictsTable().deleteAllRows();
      for (int year=Constants.FIRST_DISTRICT_YEAR; year <= maxCompYear; year++) {
        if (isCancelled()) {
          return null;
        }
        publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,String.format(context.getString(R.string.loading_districts),year)));
        AddDistrictKeys keyAdder=new AddDistrictKeys(year);
        Call<List<District>> districtListCall=datafeed.fetchDistrictListCall(year,APIv2.TBA_CACHE_WEB);
        Response<List<District>> districtListResponse=districtListCall.execute();
        if (districtListResponse == null || !districtListResponse.isSuccess() || districtListResponse.body() == null) {
          onConnectionError();
          return null;
        }
        List<District> newDistrictList=districtListResponse.body();
        keyAdder.call(newDistrictList);
        allDistricts.addAll(newDistrictList);
        Log.i(Constants.LOG_TAG,String.format("String_Node_Str",newDistrictList.size(),year));
      }
    }
    if (isCancelled()) {
      return null;
    }
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_LOADING,context.getString(R.string.loading_almost_finished)));
    Log.i(Constants.LOG_TAG,"String_Node_Str" + allTeams.size() + "String_Node_Str");
    Schedulers.io().createWorker().schedule(() -> mTeamWriter.write(allTeams));
    Log.i(Constants.LOG_TAG,"String_Node_Str" + allEvents.size() + "String_Node_Str");
    Schedulers.io().createWorker().schedule(() -> mEventWriter.write(allEvents));
    Log.i(Constants.LOG_TAG,"String_Node_Str" + allDistricts.size() + "String_Node_Str");
    Schedulers.io().createWorker().schedule(() -> mDistrictWriter.write(allDistricts));
    SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
    editor.putString(TBAStatusController.STATUS_PREF_KEY,statusResponse.body().getJsonBlob());
    editor.putInt(Constants.LAST_YEAR_KEY,statusResponse.body().getMaxSeason());
    for (int pageNum=0; pageNum <= maxPageNum; pageNum++) {
      editor.putBoolean(Database.ALL_TEAMS_LOADED_TO_DATABASE_FOR_PAGE + pageNum,true);
    }
    for (int year=Constants.FIRST_COMP_YEAR; year <= maxCompYear; year++) {
      editor.putBoolean(Database.ALL_EVENTS_LOADED_TO_DATABASE_FOR_YEAR + year,true);
    }
    for (int year=Constants.FIRST_DISTRICT_YEAR; year <= maxCompYear; year++) {
      editor.putBoolean(Database.ALL_DISTRICTS_LOADED_TO_DATABASE_FOR_YEAR + year,true);
    }
    editor.putInt(Constants.APP_VERSION_KEY,BuildConfig.VERSION_CODE);
    editor.apply();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_FINISHED,context.getString(R.string.loading_finished)));
  }
 catch (  RuntimeException ex) {
    ex.printStackTrace();
    publishProgress(new LoadProgressInfo(LoadProgressInfo.STATE_ERROR,Utilities.exceptionStacktraceToString(ex)));
  }
catch (  IOException e) {
    e.printStackTrace();
    onConnectionError();
  }
  return null;
}