Program: 19154
Project: 19154
Buggy source:
@Override protected Boolean doInBackground(long[]... params) throws Exception {
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mContext);
  AuthenticatorHelper authenticatorHelper=App.get(mContext).getAuthenticatorHelper();
  int logCount=prefs.getInt(PrefConstants.DOWNLOADING_COUNT_OF_LOGS,5);
  LocusUtils.LocusVersion locusVersion=LocusTesting.getActiveVersion(mContext);
  long[] pointIndexes=params[0];
  if (!authenticatorHelper.hasAccount())   throw new InvalidCredentialsException("String_Node_Str");
  GeocachingApi api=GeocachingApiFactory.create();
  GeocachingApi.ResultQuality resultQuality=GeocachingApi.ResultQuality.FULL;
  if (!authenticatorHelper.getRestrictions().isPremiumMember()) {
    resultQuality=GeocachingApi.ResultQuality.SUMMARY;
    logCount=0;
  }
  int current=0;
  int count=pointIndexes.length;
  int cachesPerRequest=AppConstants.CACHES_PER_REQUEST;
  try {
    login(api);
    while (current < count) {
      long startTime=System.currentTimeMillis();
      List<Waypoint> oldPoints=prepareOldWaypointsFromIndexes(mContext,locusVersion,pointIndexes,current,cachesPerRequest);
      if (oldPoints.size() == 0) {
        current+=Math.min(pointIndexes.length - current,cachesPerRequest);
        publishProgress(current);
        continue;
      }
      List<Geocache> cachesToAdd=api.searchForGeocaches(resultQuality,cachesPerRequest,logCount,0,Collections.singletonList((Filter)new CacheCodeFilter(getCachesIds(oldPoints))),null);
      authenticatorHelper.getRestrictions().updateLimits(api.getLastCacheLimits());
      if (isCancelled())       return false;
      if (cachesToAdd.size() == 0)       break;
      List<Waypoint> points=LocusDataMapper.toLocusPoints(mContext,cachesToAdd);
      for (      Waypoint p : points) {
        if (p == null || p.gcData == null)         continue;
        Waypoint oldPoint=searchOldPointByGCCode(oldPoints,p.gcData.getCacheID());
        p=LocusDataMapper.mergePoints(mContext,p,oldPoint);
        ActionTools.updateLocusWaypoint(mContext,locusVersion,p,false);
      }
      current+=Math.min(pointIndexes.length - current,cachesPerRequest);
      publishProgress(current);
      long requestDuration=System.currentTimeMillis() - startTime;
      cachesPerRequest=computeCachesPerRequest(cachesPerRequest,requestDuration);
    }
    publishProgress(current);
    Timber.i("String_Node_Str" + current);
    return current > 0;
  }
 catch (  InvalidSessionException e) {
    Timber.e(e,e.getMessage());
    authenticatorHelper.invalidateAuthToken();
    throw e;
  }
}

Fixed version (ground truth):
@Override protected Boolean doInBackground(long[]... params) throws Exception {
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mContext);
  AuthenticatorHelper authenticatorHelper=App.get(mContext).getAuthenticatorHelper();
  int logCount=prefs.getInt(PrefConstants.DOWNLOADING_COUNT_OF_LOGS,5);
  LocusUtils.LocusVersion locusVersion=LocusTesting.getActiveVersion(mContext);
  long[] pointIndexes=params[0];
  if (!authenticatorHelper.hasAccount())   throw new InvalidCredentialsException("String_Node_Str");
  GeocachingApi api=GeocachingApiFactory.create();
  GeocachingApi.ResultQuality resultQuality=GeocachingApi.ResultQuality.FULL;
  if (!authenticatorHelper.getRestrictions().isPremiumMember()) {
    resultQuality=GeocachingApi.ResultQuality.SUMMARY;
    logCount=0;
  }
  int current=0;
  int count=pointIndexes.length;
  int cachesPerRequest=AppConstants.CACHES_PER_REQUEST;
  try {
    login(api);
    while (current < count) {
      long startTime=System.currentTimeMillis();
      List<Waypoint> oldPoints=prepareOldWaypointsFromIndexes(mContext,locusVersion,pointIndexes,current,cachesPerRequest);
      if (oldPoints.size() == 0) {
        current+=Math.min(pointIndexes.length - current,cachesPerRequest);
        publishProgress(current);
        continue;
      }
      List<Geocache> cachesToAdd=api.searchForGeocaches(resultQuality,cachesPerRequest,logCount,0,Collections.singletonList((Filter)new CacheCodeFilter(getCachesIds(oldPoints))),null);
      authenticatorHelper.getRestrictions().updateLimits(api.getLastGeocacheLimits());
      if (isCancelled())       return false;
      if (cachesToAdd.size() == 0)       break;
      List<Waypoint> points=LocusDataMapper.toLocusPoints(mContext,cachesToAdd);
      for (      Waypoint p : points) {
        if (p == null || p.gcData == null)         continue;
        Waypoint oldPoint=searchOldPointByGCCode(oldPoints,p.gcData.getCacheID());
        p=LocusDataMapper.mergePoints(mContext,p,oldPoint);
        ActionTools.updateLocusWaypoint(mContext,locusVersion,p,false);
      }
      current+=Math.min(pointIndexes.length - current,cachesPerRequest);
      publishProgress(current);
      long requestDuration=System.currentTimeMillis() - startTime;
      cachesPerRequest=computeCachesPerRequest(cachesPerRequest,requestDuration);
    }
    publishProgress(current);
    Timber.i("String_Node_Str" + current);
    return current > 0;
  }
 catch (  InvalidSessionException e) {
    Timber.e(e,e.getMessage());
    authenticatorHelper.invalidateAuthToken();
    throw e;
  }
}