Buggy code:
public class ThingSyncAdapter extends AbstractThreadedSyncAdapter { public static final String TAG = "ThingSyncAdapter" ; private static final int MAX_FAILURES = 100 ; public static class Service extends android . app . Service { @ Override public IBinder onBind ( Intent intent ) { } } static class RateLimiter { long rateLimit ; boolean needExtraSync ; void updateLimit ( Result result , boolean workLeft ) { } } private static final Syncer [ ] SYNCERS = new Syncer [ ] { new VoteSyncer ( ) , new HideSyncer ( ) , new ReadSyncer ( ) , new SaveSyncer ( ) , new MessageSyncer ( ) , new CommentSyncer ( ) } ; public ThingSyncAdapter ( Context context ) { } @ Override public void onPerformSync ( Account account , Bundle extras , String authority , ContentProviderClient provider , SyncResult syncResult ) { } private void doSync ( Account account , Bundle extras , String authority , ContentProviderClient provider , SyncResult syncResult ) { } private void sync ( Account account , Bundle extras , String authority , ContentProviderClient provider , SyncResult syncResult , Syncer syncer , ThingSyncAdapter . RateLimiter limiter , String cookie , String modhash ) { Cursor c = null ; try { c = syncer . query ( provider , account . name ) ; int count = c . getCount ( ) ; if ( count == 0 ) { return ; } if ( ( limiter . rateLimit ) > 0 ) { syncResult . stats . numSkippedEntries += count ; return ; } <START_BUG> Syncer . Ops ops = new Syncer . Ops ( syncer . getEstimatedOpCount ( count ) ) ; <END_BUG> for ( ; c . moveToNext ( ) ; count -- ) { try { Result result = syncer . sync ( getContext ( ) , c , cookie , modhash ) ; if ( BuildConfig . DEBUG ) { result . logAnyErrors ( ThingSyncAdapter . TAG , syncer . getTag ( ) ) ; if ( result . hasErrors ( ) ) { Log . i ( ThingSyncAdapter . TAG , ( ( ( syncer . getTag ( ) ) + "<seq2seq4repair_space>failures:<seq2seq4repair_space>" ) + ( syncer . getSyncFailures ( c ) ) ) ) ; } } if ( result . hasRateLimitError ( ) ) { limiter . updateLimit ( result , ( count > 0 ) ) ; syncResult . stats . numSkippedEntries += count ; break ; } if ( ( ! ( result . hasErrors ( ) ) ) || ( ( syncer . getSyncFailures ( c ) ) >= ( ThingSyncAdapter . MAX_FAILURES ) ) ) { syncer . addRemoveAction ( account . name , c , ops ) ; ( syncResult . stats . numEntries ) ++ ; } else { syncer . addSyncFailure ( account . name , c , ops ) ; limiter . needExtraSync = true ; ( syncResult . stats . numSkippedEntries ) ++ ; } } catch ( IOException e ) { Log . e ( ThingSyncAdapter . TAG , e . getMessage ( ) , e ) ; ( syncResult . stats . numIoExceptions ) ++ ; } } if ( ! ( ops . isEmpty ( ) ) ) { ContentProviderResult [ ] results = provider . applyBatch ( ops ) ; syncResult . stats . numDeletes += ops . deletes ; syncResult . stats . numUpdates += ops . updates ; } } catch ( RemoteException e ) { Log . e ( ThingSyncAdapter . TAG , e . getMessage ( ) , e ) ; syncResult . databaseError = true ; } catch ( OperationApplicationException e ) { Log . e ( ThingSyncAdapter . TAG , e . getMessage ( ) , e ) ; syncResult . databaseError = true ; } finally { if ( c != null ) { c . close ( ) ; } } } }

Fix:
Ops ops = new Ops ( syncer . getEstimatedOpCount ( count ) ) ;