Program: 19155
Project: 19155
Buggy source:
@Override protected UpdateTaskData doInBackground(UpdateTaskData... params) throws Exception {
  AuthenticatorHelper authenticatorHelper=App.get(mContext).getAuthenticatorHelper();
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mContext);
  int logCount=prefs.getInt(PrefConstants.DOWNLOADING_COUNT_OF_LOGS,5);
  if (!authenticatorHelper.hasAccount())   throw new InvalidCredentialsException("String_Node_Str");
  UpdateTaskData result=params[0];
  GeocachingApi api=GeocachingApiFactory.create();
  try {
    login(api);
    publishProgress();
    int originalLogCount=logCount;
    GeocachingApi.ResultQuality resultQuality=GeocachingApi.ResultQuality.FULL;
    if (!authenticatorHelper.getRestrictions().isPremiumMember()) {
      resultQuality=GeocachingApi.ResultQuality.SUMMARY;
      logCount=0;
    }
    Geocache cache=api.getCache(resultQuality,result.cacheId,logCount,0);
    authenticatorHelper.getRestrictions().updateLimits(api.getLastCacheLimits());
    if (result.updateLogs || resultQuality == GeocachingApi.ResultQuality.SUMMARY) {
      int startIndex=logCount;
      int maxLogs=AppConstants.LOGS_TO_UPDATE_MAX - logCount;
      if (!result.updateLogs) {
        maxLogs=originalLogCount;
      }
      while (startIndex < maxLogs) {
        publishProgress(startIndex,maxLogs);
        int logsPerRequest=Math.min(maxLogs - startIndex,AppConstants.LOGS_PER_REQUEST);
        List<CacheLog> retrievedLogs=api.getCacheLogsByCacheCode(result.cacheId,startIndex,logsPerRequest);
        if (retrievedLogs == null || retrievedLogs.isEmpty()) {
          break;
        }
        cache.getCacheLogs().addAll(retrievedLogs);
        startIndex+=retrievedLogs.size();
      }
      publishProgress(maxLogs,maxLogs);
    }
    if (isCancelled())     return null;
    result.newPoint=LocusDataMapper.toLocusPoint(mContext,cache);
    return result;
  }
 catch (  InvalidSessionException e) {
    Timber.e(e,e.getMessage());
    authenticatorHelper.invalidateAuthToken();
    throw e;
  }
}

Fixed version (ground truth):
@Override protected UpdateTaskData doInBackground(UpdateTaskData... params) throws Exception {
  AuthenticatorHelper authenticatorHelper=App.get(mContext).getAuthenticatorHelper();
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mContext);
  int logCount=prefs.getInt(PrefConstants.DOWNLOADING_COUNT_OF_LOGS,5);
  if (!authenticatorHelper.hasAccount())   throw new InvalidCredentialsException("String_Node_Str");
  UpdateTaskData result=params[0];
  GeocachingApi api=GeocachingApiFactory.create();
  try {
    login(api);
    publishProgress();
    int originalLogCount=logCount;
    GeocachingApi.ResultQuality resultQuality=GeocachingApi.ResultQuality.FULL;
    if (!authenticatorHelper.getRestrictions().isPremiumMember()) {
      resultQuality=GeocachingApi.ResultQuality.SUMMARY;
      logCount=0;
    }
    Geocache cache=api.getGeocache(resultQuality,result.cacheId,logCount,0);
    authenticatorHelper.getRestrictions().updateLimits(api.getLastGeocacheLimits());
    if (result.updateLogs || resultQuality == GeocachingApi.ResultQuality.SUMMARY) {
      int startIndex=logCount;
      int maxLogs=AppConstants.LOGS_TO_UPDATE_MAX - logCount;
      if (!result.updateLogs) {
        maxLogs=originalLogCount;
      }
      while (startIndex < maxLogs) {
        publishProgress(startIndex,maxLogs);
        int logsPerRequest=Math.min(maxLogs - startIndex,AppConstants.LOGS_PER_REQUEST);
        List<GeocacheLog> retrievedLogs=api.getGeocacheLogsByCacheCode(result.cacheId,startIndex,logsPerRequest);
        if (retrievedLogs == null || retrievedLogs.isEmpty()) {
          break;
        }
        cache.getGeocacheLogs().addAll(retrievedLogs);
        startIndex+=retrievedLogs.size();
      }
      publishProgress(maxLogs,maxLogs);
    }
    if (isCancelled())     return null;
    result.newPoint=LocusDataMapper.toLocusPoint(mContext,cache);
    return result;
  }
 catch (  InvalidSessionException e) {
    Timber.e(e,e.getMessage());
    authenticatorHelper.invalidateAuthToken();
    throw e;
  }
}