nus-yam/ex-repair huggingface dataset:
Program: 152439
Project: 152439
Buggy source:
public void testPhoneUpdate(){
  ContentValues values=new ContentValues();
  Uri rawContactUri=mResolver.insert(RawContacts.CONTENT_URI,values);
  long rawContactId=ContentUris.parseId(rawContactUri);
  insertStructuredName(rawContactId,"String_Node_Str","String_Node_Str");
  Uri phoneUri=insertPhoneNumber(rawContactId,"String_Node_Str");
  Uri lookupUri1=Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,"String_Node_Str");
  assertStoredValue(lookupUri1,PhoneLookup.DISPLAY_NAME,"String_Node_Str");
  values.clear();
  values.put(Phone.NUMBER,"String_Node_Str");
  mResolver.update(phoneUri,values,null,null);
  Uri lookupUri2=Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,"String_Node_Str");
  assertStoredValue(lookupUri2,PhoneLookup.DISPLAY_NAME,"String_Node_Str");
  values.clear();
  values.putNull(Phone.NUMBER);
  mResolver.update(phoneUri,values,null,null);
  assertEquals(0,getCount(lookupUri2,null,null));
  values.clear();
  values.put(Phone.NUMBER,"String_Node_Str");
  mResolver.update(phoneUri,values,null,null);
  assertStoredValue(lookupUri2,PhoneLookup.DISPLAY_NAME,"String_Node_Str");
  assertNetworkNotified(true);
}

Fixed version (ground truth):
public void testPhoneUpdate(){
  ContentValues values=new ContentValues();
  Uri rawContactUri=mResolver.insert(RawContacts.CONTENT_URI,values);
  long rawContactId=ContentUris.parseId(rawContactUri);
  insertStructuredName(rawContactId,"String_Node_Str","String_Node_Str");
  Uri phoneUri=insertPhoneNumber(rawContactId,"String_Node_Str");
  Uri lookupUri1=Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,"String_Node_Str");
  Uri lookupUri2=Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,"String_Node_Str");
  assertEquals(2,getCount(lookupUri1,null,null));
  assertEquals(0,getCount(lookupUri2,null,null));
  values.clear();
  values.put(Phone.NUMBER,"String_Node_Str");
  mResolver.update(phoneUri,values,null,null);
  assertEquals(0,getCount(lookupUri1,null,null));
  assertEquals(2,getCount(lookupUri2,null,null));
  values.clear();
  values.putNull(Phone.NUMBER);
  mResolver.update(phoneUri,values,null,null);
  assertEquals(0,getCount(lookupUri1,null,null));
  assertEquals(0,getCount(lookupUri2,null,null));
  values.clear();
  values.put(Phone.NUMBER,"String_Node_Str");
  mResolver.update(phoneUri,values,null,null);
  assertEquals(0,getCount(lookupUri1,null,null));
  assertEquals(2,getCount(lookupUri2,null,null));
  assertNetworkNotified(true);
}
Program: 152440
Project: 152440
Buggy source:
public void testPhoneLookup(){
  ContentValues values=new ContentValues();
  values.put(RawContacts.CUSTOM_RINGTONE,"String_Node_Str");
  values.put(RawContacts.SEND_TO_VOICEMAIL,1);
  Uri rawContactUri=mResolver.insert(RawContacts.CONTENT_URI,values);
  long rawContactId=ContentUris.parseId(rawContactUri);
  insertStructuredName(rawContactId,"String_Node_Str","String_Node_Str");
  insertPhoneNumber(rawContactId,"String_Node_Str");
  Uri lookupUri1=Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,"String_Node_Str");
  values.clear();
  values.put(PhoneLookup._ID,queryContactId(rawContactId));
  values.put(PhoneLookup.DISPLAY_NAME,"String_Node_Str");
  values.put(PhoneLookup.NUMBER,"String_Node_Str");
  values.put(PhoneLookup.TYPE,Phone.TYPE_HOME);
  values.putNull(PhoneLookup.LABEL);
  values.put(PhoneLookup.CUSTOM_RINGTONE,"String_Node_Str");
  values.put(PhoneLookup.SEND_TO_VOICEMAIL,1);
  assertStoredValues(lookupUri1,values);
  Uri lookupUri2=Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,"String_Node_Str");
  assertEquals(2,getCount(lookupUri2,null,null));
}

Fixed version (ground truth):
public void testPhoneLookup(){
  ContentValues values=new ContentValues();
  values.put(RawContacts.CUSTOM_RINGTONE,"String_Node_Str");
  values.put(RawContacts.SEND_TO_VOICEMAIL,1);
  Uri rawContactUri=mResolver.insert(RawContacts.CONTENT_URI,values);
  long rawContactId=ContentUris.parseId(rawContactUri);
  insertStructuredName(rawContactId,"String_Node_Str","String_Node_Str");
  insertPhoneNumber(rawContactId,"String_Node_Str");
  Uri lookupUri1=Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,"String_Node_Str");
  values.clear();
  values.put(PhoneLookup._ID,queryContactId(rawContactId));
  values.put(PhoneLookup.DISPLAY_NAME,"String_Node_Str");
  values.put(PhoneLookup.NUMBER,"String_Node_Str");
  values.put(PhoneLookup.TYPE,Phone.TYPE_HOME);
  values.putNull(PhoneLookup.LABEL);
  values.put(PhoneLookup.CUSTOM_RINGTONE,"String_Node_Str");
  values.put(PhoneLookup.SEND_TO_VOICEMAIL,1);
  assertStoredValues(lookupUri1,null,null,new ContentValues[]{values,values});
  Uri lookupUri2=Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,"String_Node_Str");
  assertEquals(2,getCount(lookupUri2,null,null));
}
Program: 152441
Project: 152441
Buggy source:
private void appendPhoneLookupSelection(StringBuilder sb,String number,String numberE164){
  sb.append("String_Node_Str");
  boolean hasNumberE164=!TextUtils.isEmpty(numberE164);
  boolean hasNumber=!TextUtils.isEmpty(number);
  if (hasNumberE164 || hasNumber) {
    sb.append("String_Node_Str");
    if (hasNumberE164) {
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,numberE164);
    }
    if (hasNumberE164 && hasNumber) {
      sb.append("String_Node_Str");
    }
    if (hasNumber) {
      int numberLen=number.length();
      sb.append("String_Node_Str");
      sb.append(numberLen);
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,number);
      sb.append(',');
      sb.append(numberLen);
      sb.append("String_Node_Str");
      if (!hasNumberE164) {
        sb.append("String_Node_Str");
        sb.append("String_Node_Str");
        sb.append(numberLen);
        sb.append("String_Node_Str");
        sb.append("String_Node_Str");
        sb.append(numberLen);
        sb.append("String_Node_Str");
        DatabaseUtils.appendEscapedSQLString(sb,number);
        sb.append("String_Node_Str");
      }
    }
    sb.append(')');
  }
}

Fixed version (ground truth):
private void appendPhoneLookupSelection(StringBuilder sb,String number,String numberE164){
  sb.append("String_Node_Str");
  boolean hasNumberE164=!TextUtils.isEmpty(numberE164);
  boolean hasNumber=!TextUtils.isEmpty(number);
  if (hasNumberE164 || hasNumber) {
    sb.append("String_Node_Str");
    if (hasNumberE164) {
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,numberE164);
    }
    if (hasNumberE164 && hasNumber) {
      sb.append("String_Node_Str");
    }
    if (hasNumber) {
      int numberLen=number.length();
      sb.append("String_Node_Str");
      sb.append(numberLen);
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,number);
      sb.append(',');
      sb.append(numberLen);
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append(numberLen);
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append(numberLen);
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,number);
      sb.append("String_Node_Str");
    }
    sb.append(')');
  }
}
Program: 152442
Project: 152442
Buggy source:
/** 
 * Finds all distinct account types and data sets present in the specified table.
 */
private Set<AccountWithDataSet> findValidAccountsWithDataSets(String table){
  Set<AccountWithDataSet> accountsWithDataSets=new HashSet<AccountWithDataSet>();
  Cursor c=mActiveDb.get().rawQuery("String_Node_Str" + RawContacts.ACCOUNT_NAME + "String_Node_Str"+ RawContacts.ACCOUNT_TYPE+ "String_Node_Str"+ RawContacts.DATA_SET+ "String_Node_Str"+ table,null);
  try {
    while (c.moveToNext()) {
      if (!c.isNull(0) || !c.isNull(1)) {
        accountsWithDataSets.add(new AccountWithDataSet(c.getString(0),c.getString(1),c.getString(2)));
      }
    }
  }
  finally {
    c.close();
  }
  return accountsWithDataSets;
}

Fixed version (ground truth):
/** 
 * Finds all distinct account types and data sets present in the specified table.
 */
private Set<AccountWithDataSet> findValidAccountsWithDataSets(String table){
  Set<AccountWithDataSet> accountsWithDataSets=new HashSet<AccountWithDataSet>();
  Cursor c=mActiveDb.get().rawQuery("String_Node_Str" + RawContacts.ACCOUNT_NAME + "String_Node_Str"+ RawContacts.ACCOUNT_TYPE+ "String_Node_Str"+ RawContacts.DATA_SET+ "String_Node_Str"+ table,null);
  try {
    while (c.moveToNext()) {
      if (!c.isNull(0) && !c.isNull(1)) {
        accountsWithDataSets.add(new AccountWithDataSet(c.getString(0),c.getString(1),c.getString(2)));
      }
    }
  }
  finally {
    c.close();
  }
  return accountsWithDataSets;
}
Program: 152443
Project: 152443
Buggy source:
/** 
 * Finds all distinct account types and data sets present in the specified table.
 */
private Set<AccountWithDataSet> findValidAccountsWithDataSets(String table){
  Set<AccountWithDataSet> accountsWithDataSets=new HashSet<AccountWithDataSet>();
  Cursor c=mActiveDb.get().rawQuery("String_Node_Str" + RawContacts.ACCOUNT_NAME + "String_Node_Str"+ RawContacts.ACCOUNT_TYPE+ "String_Node_Str"+ RawContacts.DATA_SET+ "String_Node_Str"+ table,null);
  try {
    while (c.moveToNext()) {
      if (!c.isNull(0) || !c.isNull(1)) {
        accountsWithDataSets.add(new AccountWithDataSet(c.getString(0),c.getString(1),c.getString(2)));
      }
    }
  }
  finally {
    c.close();
  }
  return accountsWithDataSets;
}

Fixed version (ground truth):
/** 
 * Finds all distinct account types and data sets present in the specified table.
 */
private Set<AccountWithDataSet> findValidAccountsWithDataSets(String table){
  Set<AccountWithDataSet> accountsWithDataSets=new HashSet<AccountWithDataSet>();
  Cursor c=mActiveDb.get().rawQuery("String_Node_Str" + RawContacts.ACCOUNT_NAME + "String_Node_Str"+ RawContacts.ACCOUNT_TYPE+ "String_Node_Str"+ RawContacts.DATA_SET+ "String_Node_Str"+ table,null);
  try {
    while (c.moveToNext()) {
      if (!c.isNull(0) && !c.isNull(1)) {
        accountsWithDataSets.add(new AccountWithDataSet(c.getString(0),c.getString(1),c.getString(2)));
      }
    }
  }
  finally {
    c.close();
  }
  return accountsWithDataSets;
}
Program: 152446
Project: 152446
Buggy source:
@Override public int bulkInsert(Uri uri,ContentValues[] values){
  waitForAccess(mWriteAccessLatch);
  int numValues=values.length;
  boolean notifyChange=false;
  SQLiteDatabase profileDb=null;
  SQLiteDatabase contactsDb=mContactsHelper.getWritableDatabase();
  contactsDb.beginTransactionWithListener(this);
  try {
    for (int i=0; i < numValues; i++) {
      Uri result;
      if (mapsToProfileDbWithInsertedValues(uri,values[i])) {
        switchToProfileMode();
        if (profileDb == null) {
          profileDb=mProfileHelper.getWritableDatabase();
          profileDb.beginTransactionWithListener(this);
        }
        result=mProfileProvider.insertInTransaction(uri,values[i]);
      }
 else {
        switchToContactMode();
        result=insertInTransaction(uri,values[i]);
      }
      if (result != null) {
        notifyChange=true;
      }
      boolean savedNotifyChange=notifyChange;
      mActiveDb.get().yieldIfContendedSafely();
      notifyChange=savedNotifyChange;
    }
    contactsDb.setTransactionSuccessful();
    if (profileDb != null) {
      profileDb.setTransactionSuccessful();
    }
  }
  finally {
    contactsDb.endTransaction();
    if (profileDb != null) {
      profileDb.endTransaction();
    }
  }
  if (notifyChange) {
    notifyChange();
  }
  return numValues;
}

Fixed version (ground truth):
@Override public int bulkInsert(Uri uri,ContentValues[] values){
  waitForAccess(mWriteAccessLatch);
  int numValues=values.length;
  boolean notifyChange=false;
  SQLiteDatabase profileDb=null;
  mDb=mContactsHelper.getWritableDatabase();
  mDb.beginTransactionWithListener(this);
  try {
    for (int i=0; i < numValues; i++) {
      Uri result;
      if (mapsToProfileDbWithInsertedValues(uri,values[i])) {
        switchToProfileMode();
        if (profileDb == null) {
          profileDb=mProfileHelper.getWritableDatabase();
          profileDb.beginTransactionWithListener(this);
        }
        result=mProfileProvider.insertInTransaction(uri,values[i]);
      }
 else {
        switchToContactMode();
        result=insertInTransaction(uri,values[i]);
      }
      if (result != null) {
        notifyChange=true;
      }
      boolean savedNotifyChange=notifyChange;
      mActiveDb.get().yieldIfContendedSafely();
      notifyChange=savedNotifyChange;
    }
    mDb.setTransactionSuccessful();
    if (profileDb != null) {
      profileDb.setTransactionSuccessful();
    }
  }
  finally {
    mDb.endTransaction();
    if (profileDb != null) {
      profileDb.endTransaction();
    }
  }
  if (notifyChange) {
    notifyChange();
  }
  return numValues;
}
Program: 152449
Project: 152449
Buggy source:
@Override public int bulkInsert(Uri uri,ContentValues[] values){
  waitForAccess(mWriteAccessLatch);
  int numValues=values.length;
  boolean notifyChange=false;
  SQLiteDatabase profileDb=null;
  SQLiteDatabase contactsDb=mContactsHelper.getWritableDatabase();
  contactsDb.beginTransactionWithListener(this);
  try {
    for (int i=0; i < numValues; i++) {
      Uri result;
      if (mapsToProfileDbWithInsertedValues(uri,values[i])) {
        switchToProfileMode();
        if (profileDb == null) {
          profileDb=mProfileHelper.getWritableDatabase();
          profileDb.beginTransactionWithListener(this);
        }
        result=mProfileProvider.insertInTransaction(uri,values[i]);
      }
 else {
        switchToContactMode();
        result=insertInTransaction(uri,values[i]);
      }
      if (result != null) {
        notifyChange=true;
      }
      boolean savedNotifyChange=notifyChange;
      mActiveDb.get().yieldIfContendedSafely();
      notifyChange=savedNotifyChange;
    }
    contactsDb.setTransactionSuccessful();
    if (profileDb != null) {
      profileDb.setTransactionSuccessful();
    }
  }
  finally {
    contactsDb.endTransaction();
    if (profileDb != null) {
      profileDb.endTransaction();
    }
  }
  if (notifyChange) {
    notifyChange();
  }
  return numValues;
}

Fixed version (ground truth):
@Override public int bulkInsert(Uri uri,ContentValues[] values){
  waitForAccess(mWriteAccessLatch);
  int numValues=values.length;
  boolean notifyChange=false;
  SQLiteDatabase profileDb=null;
  mDb=mContactsHelper.getWritableDatabase();
  mDb.beginTransactionWithListener(this);
  try {
    for (int i=0; i < numValues; i++) {
      Uri result;
      if (mapsToProfileDbWithInsertedValues(uri,values[i])) {
        switchToProfileMode();
        if (profileDb == null) {
          profileDb=mProfileHelper.getWritableDatabase();
          profileDb.beginTransactionWithListener(this);
        }
        result=mProfileProvider.insertInTransaction(uri,values[i]);
      }
 else {
        switchToContactMode();
        result=insertInTransaction(uri,values[i]);
      }
      if (result != null) {
        notifyChange=true;
      }
      boolean savedNotifyChange=notifyChange;
      mActiveDb.get().yieldIfContendedSafely();
      notifyChange=savedNotifyChange;
    }
    mDb.setTransactionSuccessful();
    if (profileDb != null) {
      profileDb.setTransactionSuccessful();
    }
  }
  finally {
    mDb.endTransaction();
    if (profileDb != null) {
      profileDb.endTransaction();
    }
  }
  if (notifyChange) {
    notifyChange();
  }
  return numValues;
}
Program: 152451
Project: 152451
Buggy source:
private boolean shouldIncludeProfile(Uri uri){
  boolean profileRequested=readBooleanQueryParameter(uri,ContactsContract.ALLOW_PROFILE,false);
  if (profileRequested) {
    enforceProfilePermission(false);
  }
  return profileRequested;
}

Fixed version (ground truth):
private boolean shouldIncludeProfile(Uri uri,boolean suppressProfileCheck){
  boolean profileRequested=readBooleanQueryParameter(uri,ContactsContract.ALLOW_PROFILE,false);
  if (profileRequested && !suppressProfileCheck) {
    enforceProfilePermission(false);
  }
  return profileRequested;
}
Program: 152452
Project: 152452
Buggy source:
private void appendProfileRestriction(SQLiteQueryBuilder qb,Uri uri,String profileColumn,boolean andRequired){
  if (!shouldIncludeProfile(uri)) {
    qb.appendWhere((andRequired ? "String_Node_Str" : "String_Node_Str") + profileColumn + "String_Node_Str"+ profileColumn+ "String_Node_Str"+ (andRequired ? "String_Node_Str" : "String_Node_Str"));
  }
}

Fixed version (ground truth):
private void appendProfileRestriction(SQLiteQueryBuilder qb,Uri uri,String profileColumn,boolean andRequired,boolean suppressProfileCheck){
  if (!shouldIncludeProfile(uri,suppressProfileCheck)) {
    qb.appendWhere((andRequired ? "String_Node_Str" : "String_Node_Str") + profileColumn + "String_Node_Str"+ profileColumn+ "String_Node_Str"+ (andRequired ? "String_Node_Str" : "String_Node_Str"));
  }
}
Program: 152453
Project: 152453
Buggy source:
private String prependProfileSortIfNeeded(Uri uri,String sortOrder){
  if (shouldIncludeProfile(uri)) {
    if (TextUtils.isEmpty(sortOrder)) {
      return Contacts.IS_USER_PROFILE + "String_Node_Str";
    }
 else {
      return Contacts.IS_USER_PROFILE + "String_Node_Str" + sortOrder;
    }
  }
  return sortOrder;
}

Fixed version (ground truth):
private String prependProfileSortIfNeeded(Uri uri,String sortOrder,boolean suppressProfileCheck){
  if (shouldIncludeProfile(uri,suppressProfileCheck)) {
    if (TextUtils.isEmpty(sortOrder)) {
      return Contacts.IS_USER_PROFILE + "String_Node_Str";
    }
 else {
      return Contacts.IS_USER_PROFILE + "String_Node_Str" + sortOrder;
    }
  }
  return sortOrder;
}
Program: 152455
Project: 152455
Buggy source:
private boolean shouldIncludeProfile(Uri uri){
  boolean profileRequested=readBooleanQueryParameter(uri,ContactsContract.ALLOW_PROFILE,false);
  if (profileRequested) {
    enforceProfilePermission(false);
  }
  return profileRequested;
}

Fixed version (ground truth):
private boolean shouldIncludeProfile(Uri uri,boolean suppressProfileCheck){
  boolean profileRequested=readBooleanQueryParameter(uri,ContactsContract.ALLOW_PROFILE,false);
  if (profileRequested && !suppressProfileCheck) {
    enforceProfilePermission(false);
  }
  return profileRequested;
}
Program: 152456
Project: 152456
Buggy source:
private void appendProfileRestriction(SQLiteQueryBuilder qb,Uri uri,String profileColumn,boolean andRequired){
  if (!shouldIncludeProfile(uri)) {
    qb.appendWhere((andRequired ? "String_Node_Str" : "String_Node_Str") + profileColumn + "String_Node_Str"+ profileColumn+ "String_Node_Str"+ (andRequired ? "String_Node_Str" : "String_Node_Str"));
  }
}

Fixed version (ground truth):
private void appendProfileRestriction(SQLiteQueryBuilder qb,Uri uri,String profileColumn,boolean andRequired,boolean suppressProfileCheck){
  if (!shouldIncludeProfile(uri,suppressProfileCheck)) {
    qb.appendWhere((andRequired ? "String_Node_Str" : "String_Node_Str") + profileColumn + "String_Node_Str"+ profileColumn+ "String_Node_Str"+ (andRequired ? "String_Node_Str" : "String_Node_Str"));
  }
}
Program: 152457
Project: 152457
Buggy source:
private String prependProfileSortIfNeeded(Uri uri,String sortOrder){
  if (shouldIncludeProfile(uri)) {
    if (TextUtils.isEmpty(sortOrder)) {
      return Contacts.IS_USER_PROFILE + "String_Node_Str";
    }
 else {
      return Contacts.IS_USER_PROFILE + "String_Node_Str" + sortOrder;
    }
  }
  return sortOrder;
}

Fixed version (ground truth):
private String prependProfileSortIfNeeded(Uri uri,String sortOrder,boolean suppressProfileCheck){
  if (shouldIncludeProfile(uri,suppressProfileCheck)) {
    if (TextUtils.isEmpty(sortOrder)) {
      return Contacts.IS_USER_PROFILE + "String_Node_Str";
    }
 else {
      return Contacts.IS_USER_PROFILE + "String_Node_Str" + sortOrder;
    }
  }
  return sortOrder;
}
Program: 152458
Project: 152458
Buggy source:
private CursorWrapper wrapCursor(Uri uri,Cursor cursor){
  String[] args=null;
  String snippetArgs=getQueryParameter(uri,SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY);
  if (snippetArgs != null) {
    args=snippetArgs.split("String_Node_Str");
  }
  String query=uri.getLastPathSegment();
  String startMatch=args != null && args.length > 0 ? args[0] : DEFAULT_SNIPPET_ARG_START_MATCH;
  String endMatch=args != null && args.length > 1 ? args[1] : DEFAULT_SNIPPET_ARG_END_MATCH;
  String ellipsis=args != null && args.length > 2 ? args[2] : DEFAULT_SNIPPET_ARG_ELLIPSIS;
  int maxTokens=args != null && args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_SNIPPET_ARG_MAX_TOKENS;
  CrossProcessCursor crossProcessCursor=getCrossProcessCursor(cursor);
  if (crossProcessCursor != null) {
    return new SnippetizingCursorWrapper(cursor,query,startMatch,endMatch,ellipsis,maxTokens);
  }
 else {
    return new SnippetizingCursorWrapper(matrixCursorFromCursor(cursor),query,startMatch,endMatch,ellipsis,maxTokens);
  }
}

Fixed version (ground truth):
private Cursor wrapCursor(Uri uri,Cursor cursor){
  if (cursor.getColumnIndex(SearchSnippetColumns.SNIPPET) < 0) {
    return cursor;
  }
  String[] args=null;
  String snippetArgs=getQueryParameter(uri,SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY);
  if (snippetArgs != null) {
    args=snippetArgs.split("String_Node_Str");
  }
  String query=uri.getLastPathSegment();
  String startMatch=args != null && args.length > 0 ? args[0] : DEFAULT_SNIPPET_ARG_START_MATCH;
  String endMatch=args != null && args.length > 1 ? args[1] : DEFAULT_SNIPPET_ARG_END_MATCH;
  String ellipsis=args != null && args.length > 2 ? args[2] : DEFAULT_SNIPPET_ARG_ELLIPSIS;
  int maxTokens=args != null && args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_SNIPPET_ARG_MAX_TOKENS;
  return new SnippetizingCursorWrapper(cursor,query,startMatch,endMatch,ellipsis,maxTokens);
}
Program: 152459
Project: 152459
Buggy source:
private CursorWrapper wrapCursor(Uri uri,Cursor cursor){
  String[] args=null;
  String snippetArgs=getQueryParameter(uri,SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY);
  if (snippetArgs != null) {
    args=snippetArgs.split("String_Node_Str");
  }
  String query=uri.getLastPathSegment();
  String startMatch=args != null && args.length > 0 ? args[0] : DEFAULT_SNIPPET_ARG_START_MATCH;
  String endMatch=args != null && args.length > 1 ? args[1] : DEFAULT_SNIPPET_ARG_END_MATCH;
  String ellipsis=args != null && args.length > 2 ? args[2] : DEFAULT_SNIPPET_ARG_ELLIPSIS;
  int maxTokens=args != null && args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_SNIPPET_ARG_MAX_TOKENS;
  CrossProcessCursor crossProcessCursor=getCrossProcessCursor(cursor);
  if (crossProcessCursor != null) {
    return new SnippetizingCursorWrapper(cursor,query,startMatch,endMatch,ellipsis,maxTokens);
  }
 else {
    return new SnippetizingCursorWrapper(matrixCursorFromCursor(cursor),query,startMatch,endMatch,ellipsis,maxTokens);
  }
}

Fixed version (ground truth):
private Cursor wrapCursor(Uri uri,Cursor cursor){
  if (cursor.getColumnIndex(SearchSnippetColumns.SNIPPET) < 0) {
    return cursor;
  }
  String[] args=null;
  String snippetArgs=getQueryParameter(uri,SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY);
  if (snippetArgs != null) {
    args=snippetArgs.split("String_Node_Str");
  }
  String query=uri.getLastPathSegment();
  String startMatch=args != null && args.length > 0 ? args[0] : DEFAULT_SNIPPET_ARG_START_MATCH;
  String endMatch=args != null && args.length > 1 ? args[1] : DEFAULT_SNIPPET_ARG_END_MATCH;
  String ellipsis=args != null && args.length > 2 ? args[2] : DEFAULT_SNIPPET_ARG_ELLIPSIS;
  int maxTokens=args != null && args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_SNIPPET_ARG_MAX_TOKENS;
  return new SnippetizingCursorWrapper(cursor,query,startMatch,endMatch,ellipsis,maxTokens);
}
Program: 152461
Project: 152461
Buggy source:
/** 
 * Finds name lookup records matching the supplied filter, picks one arbitrary match per contact and joins that with other contacts tables.
 */
private void setTablesAndProjectionMapForContactsWithSnippet(SQLiteQueryBuilder qb,Uri uri,String[] projection,String filter,long directoryId){
  StringBuilder sb=new StringBuilder();
  sb.append(mDbHelper.getContactView(shouldExcludeRestrictedData(uri)));
  if (filter != null) {
    filter=filter.trim();
  }
  if (TextUtils.isEmpty(filter) || directoryId != Directory.DEFAULT) {
    sb.append("String_Node_Str" + SearchSnippetColumns.SNIPPET + "String_Node_Str");
  }
 else {
    appendSearchIndexJoin(sb,uri,projection,filter);
  }
  appendContactPresenceJoin(sb,projection,Contacts._ID);
  appendContactStatusUpdateJoin(sb,projection,ContactsColumns.LAST_STATUS_UPDATE_ID);
  qb.setTables(sb.toString());
  qb.setProjectionMap(sContactsProjectionWithSnippetMap);
}

Fixed version (ground truth):
/** 
 * Finds name lookup records matching the supplied filter, picks one arbitrary match per contact and joins that with other contacts tables.
 */
private void setTablesAndProjectionMapForContactsWithSnippet(SQLiteQueryBuilder qb,Uri uri,String[] projection,String filter,long directoryId){
  StringBuilder sb=new StringBuilder();
  sb.append(mDbHelper.getContactView(shouldExcludeRestrictedData(uri)));
  if (filter != null) {
    filter=filter.trim();
  }
  if (TextUtils.isEmpty(filter) || (directoryId != -1 && directoryId != Directory.DEFAULT)) {
    sb.append("String_Node_Str" + SearchSnippetColumns.SNIPPET + "String_Node_Str");
  }
 else {
    appendSearchIndexJoin(sb,uri,projection,filter);
  }
  appendContactPresenceJoin(sb,projection,Contacts._ID);
  appendContactStatusUpdateJoin(sb,projection,ContactsColumns.LAST_STATUS_UPDATE_ID);
  qb.setTables(sb.toString());
  qb.setProjectionMap(sContactsProjectionWithSnippetMap);
}
Program: 152462
Project: 152462
Buggy source:
@Override public void appendSearchableData(IndexBuilder builder){
  String number=builder.getString(Phone.NUMBER);
  String normalizedNumber=PhoneNumberUtils.normalizeNumber(number);
  if (TextUtils.isEmpty(normalizedNumber)) {
    return;
  }
  builder.appendToken(normalizedNumber);
  String numberE164=PhoneNumberUtils.formatNumberToE164(number,mDbHelper.getCurrentCountryIso());
  if (numberE164 != null && !numberE164.equals(normalizedNumber)) {
    builder.appendToken(numberE164);
  }
}

Fixed version (ground truth):
@Override public void appendSearchableData(IndexBuilder builder){
  String number=builder.getString(Phone.NUMBER);
  if (TextUtils.isEmpty(number)) {
    return;
  }
  String normalizedNumber=PhoneNumberUtils.normalizeNumber(number);
  if (TextUtils.isEmpty(normalizedNumber)) {
    return;
  }
  builder.appendToken(normalizedNumber);
  String numberE164=PhoneNumberUtils.formatNumberToE164(number,mDbHelper.getCurrentCountryIso());
  if (numberE164 != null && !numberE164.equals(normalizedNumber)) {
    builder.appendToken(numberE164);
  }
}
Program: 152463
Project: 152463
Buggy source:
@Override public void appendSearchableData(IndexBuilder builder){
  builder.appendTokenFromColumn(StructuredName.PREFIX);
  builder.appendTokenFromColumn(StructuredName.FAMILY_NAME);
  builder.appendTokenFromColumn(StructuredName.GIVEN_NAME);
  builder.appendTokenFromColumn(StructuredName.MIDDLE_NAME);
  builder.appendTokenFromColumn(StructuredName.SUFFIX);
  builder.appendTokenFromColumn(StructuredName.PHONETIC_FAMILY_NAME);
  builder.appendTokenFromColumn(StructuredName.PHONETIC_MIDDLE_NAME);
  builder.appendTokenFromColumn(StructuredName.PHONETIC_GIVEN_NAME);
}

Fixed version (ground truth):
@Override public void appendSearchableData(IndexBuilder builder){
  builder.appendTokenFromColumn(StructuredName.PREFIX);
  builder.appendTokenFromColumn(StructuredName.FAMILY_NAME);
  builder.appendTokenFromColumn(StructuredName.GIVEN_NAME);
  builder.appendTokenFromColumn(StructuredName.MIDDLE_NAME);
  builder.appendTokenFromColumn(StructuredName.SUFFIX);
  String phoneticFamily=builder.getString(StructuredName.PHONETIC_FAMILY_NAME);
  String phoneticMiddle=builder.getString(StructuredName.PHONETIC_MIDDLE_NAME);
  String phoneticGiven=builder.getString(StructuredName.PHONETIC_GIVEN_NAME);
  if (!TextUtils.isEmpty(phoneticFamily) || !TextUtils.isEmpty(phoneticMiddle) || !TextUtils.isEmpty(phoneticGiven)) {
    mSb.setLength(0);
    if (!TextUtils.isEmpty(phoneticFamily)) {
      builder.appendToken(phoneticFamily);
      mSb.append(phoneticFamily);
    }
    if (!TextUtils.isEmpty(phoneticMiddle)) {
      builder.appendToken(phoneticMiddle);
      mSb.append(phoneticMiddle);
    }
    if (!TextUtils.isEmpty(phoneticGiven)) {
      builder.appendToken(phoneticGiven);
      mSb.append(phoneticGiven);
    }
    builder.appendToken(mSb.toString().trim());
  }
}
Program: 152464
Project: 152464
Buggy source:
public void testSearchSnippetEmail() throws Exception {
  long rawContactId=createRawContact();
  long contactId=queryContactId(rawContactId);
  ContentValues values=new ContentValues();
  Uri dataUri=insertEmail(rawContactId,"String_Node_Str",true,Email.TYPE_CUSTOM,"String_Node_Str");
  Uri filterUri=Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,Uri.encode("String_Node_Str"));
  values.clear();
  values.put(Contacts._ID,contactId);
  values.put(SearchSnippetColumns.SNIPPET_DATA1,"String_Node_Str");
  values.put(SearchSnippetColumns.SNIPPET_DATA_ID,ContentUris.parseId(dataUri));
  values.put(SearchSnippetColumns.SNIPPET_MIMETYPE,Email.CONTENT_ITEM_TYPE);
  values.put(SearchSnippetColumns.SNIPPET_DATA2,Email.TYPE_CUSTOM);
  values.put(SearchSnippetColumns.SNIPPET_DATA3,"String_Node_Str");
  assertStoredValues(filterUri,values);
}

Fixed version (ground truth):
public void testSearchSnippetEmail() throws Exception {
  long rawContactId=createRawContact();
  long contactId=queryContactId(rawContactId);
  ContentValues values=new ContentValues();
  Uri dataUri=insertEmail(rawContactId,"String_Node_Str",true,Email.TYPE_CUSTOM,"String_Node_Str");
  Uri filterUri=Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,Uri.encode("String_Node_Str"));
  values.clear();
  values.put(Contacts._ID,contactId);
  values.put(SearchSnippetColumns.SNIPPET,"String_Node_Str");
  assertStoredValues(filterUri,values);
}
Program: 152465
Project: 152465
Buggy source:
public void testSearchSnippetNickname() throws Exception {
  long rawContactId=createRawContactWithName();
  long contactId=queryContactId(rawContactId);
  ContentValues values=new ContentValues();
  Uri dataUri=insertNickname(rawContactId,"String_Node_Str");
  Uri filterUri=Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,Uri.encode("String_Node_Str"));
  values.clear();
  values.put(Contacts._ID,contactId);
  values.put(SearchSnippetColumns.SNIPPET_DATA1,"String_Node_Str");
  values.put(SearchSnippetColumns.SNIPPET_DATA_ID,ContentUris.parseId(dataUri));
  values.put(SearchSnippetColumns.SNIPPET_MIMETYPE,Nickname.CONTENT_ITEM_TYPE);
  assertStoredValues(filterUri,values);
}

Fixed version (ground truth):
public void testSearchSnippetNickname() throws Exception {
  long rawContactId=createRawContactWithName();
  long contactId=queryContactId(rawContactId);
  ContentValues values=new ContentValues();
  Uri dataUri=insertNickname(rawContactId,"String_Node_Str");
  Uri filterUri=Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,Uri.encode("String_Node_Str"));
  values.clear();
  values.put(Contacts._ID,contactId);
  values.put(SearchSnippetColumns.SNIPPET,"String_Node_Str");
  assertStoredValues(filterUri,values);
}
Program: 152466
Project: 152466
Buggy source:
public void testContactsWithSnippetProjection(){
  assertProjection(Contacts.CONTENT_FILTER_URI.buildUpon().appendPath("String_Node_Str").build(),new String[]{Contacts._ID,Contacts.DISPLAY_NAME_PRIMARY,Contacts.DISPLAY_NAME_ALTERNATIVE,Contacts.DISPLAY_NAME_SOURCE,Contacts.PHONETIC_NAME,Contacts.PHONETIC_NAME_STYLE,Contacts.SORT_KEY_PRIMARY,Contacts.SORT_KEY_ALTERNATIVE,Contacts.LAST_TIME_CONTACTED,Contacts.TIMES_CONTACTED,Contacts.STARRED,Contacts.IN_VISIBLE_GROUP,Contacts.PHOTO_ID,Contacts.PHOTO_URI,Contacts.PHOTO_THUMBNAIL_URI,Contacts.CUSTOM_RINGTONE,Contacts.HAS_PHONE_NUMBER,Contacts.SEND_TO_VOICEMAIL,Contacts.LOOKUP_KEY,Contacts.NAME_RAW_CONTACT_ID,Contacts.CONTACT_PRESENCE,Contacts.CONTACT_CHAT_CAPABILITY,Contacts.CONTACT_STATUS,Contacts.CONTACT_STATUS_TIMESTAMP,Contacts.CONTACT_STATUS_RES_PACKAGE,Contacts.CONTACT_STATUS_LABEL,Contacts.CONTACT_STATUS_ICON,SearchSnippetColumns.SNIPPET_MIMETYPE,SearchSnippetColumns.SNIPPET_DATA_ID,SearchSnippetColumns.SNIPPET_DATA1,SearchSnippetColumns.SNIPPET_DATA2,SearchSnippetColumns.SNIPPET_DATA3,SearchSnippetColumns.SNIPPET_DATA4});
}

Fixed version (ground truth):
public void testContactsWithSnippetProjection(){
  assertProjection(Contacts.CONTENT_FILTER_URI.buildUpon().appendPath("String_Node_Str").build(),new String[]{Contacts._ID,Contacts.DISPLAY_NAME_PRIMARY,Contacts.DISPLAY_NAME_ALTERNATIVE,Contacts.DISPLAY_NAME_SOURCE,Contacts.PHONETIC_NAME,Contacts.PHONETIC_NAME_STYLE,Contacts.SORT_KEY_PRIMARY,Contacts.SORT_KEY_ALTERNATIVE,Contacts.LAST_TIME_CONTACTED,Contacts.TIMES_CONTACTED,Contacts.STARRED,Contacts.IN_VISIBLE_GROUP,Contacts.PHOTO_ID,Contacts.PHOTO_URI,Contacts.PHOTO_THUMBNAIL_URI,Contacts.CUSTOM_RINGTONE,Contacts.HAS_PHONE_NUMBER,Contacts.SEND_TO_VOICEMAIL,Contacts.LOOKUP_KEY,Contacts.NAME_RAW_CONTACT_ID,Contacts.CONTACT_PRESENCE,Contacts.CONTACT_CHAT_CAPABILITY,Contacts.CONTACT_STATUS,Contacts.CONTACT_STATUS_TIMESTAMP,Contacts.CONTACT_STATUS_RES_PACKAGE,Contacts.CONTACT_STATUS_LABEL,Contacts.CONTACT_STATUS_ICON,SearchSnippetColumns.SNIPPET});
}
Program: 152467
Project: 152467
Buggy source:
public void testSearchSnippetOrganization() throws Exception {
  long rawContactId=createRawContactWithName();
  long contactId=queryContactId(rawContactId);
  insertEmail(rawContactId,"String_Node_Str");
  ContentValues values=new ContentValues();
  values.clear();
  values.put(Organization.COMPANY,"String_Node_Str");
  values.put(Organization.TITLE,"String_Node_Str");
  Uri organizationUri=insertOrganization(rawContactId,values);
  values.put(Organization.COMPANY,"String_Node_Str");
  insertOrganization(rawContactId,values);
  values.put(Organization.COMPANY,"String_Node_Str");
  insertOrganization(rawContactId,values);
  insertEmail(rawContactId,"String_Node_Str",true,Email.TYPE_CUSTOM,"String_Node_Str");
  Uri filterUri=Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,Uri.encode("String_Node_Str"));
  values.clear();
  values.put(Contacts._ID,contactId);
  values.put(SearchSnippetColumns.SNIPPET_DATA_ID,ContentUris.parseId(organizationUri));
  values.put(SearchSnippetColumns.SNIPPET_DATA1,"String_Node_Str");
  values.put(SearchSnippetColumns.SNIPPET_DATA4,"String_Node_Str");
  values.put(SearchSnippetColumns.SNIPPET_MIMETYPE,Organization.CONTENT_ITEM_TYPE);
  assertStoredValues(filterUri,values);
}

Fixed version (ground truth):
public void testSearchSnippetOrganization() throws Exception {
  long rawContactId=createRawContactWithName();
  long contactId=queryContactId(rawContactId);
  insertEmail(rawContactId,"String_Node_Str");
  ContentValues values=new ContentValues();
  values.clear();
  values.put(Organization.COMPANY,"String_Node_Str");
  values.put(Organization.TITLE,"String_Node_Str");
  Uri organizationUri=insertOrganization(rawContactId,values);
  values.put(Organization.COMPANY,"String_Node_Str");
  insertOrganization(rawContactId,values);
  values.put(Organization.COMPANY,"String_Node_Str");
  insertOrganization(rawContactId,values);
  insertEmail(rawContactId,"String_Node_Str",true,Email.TYPE_CUSTOM,"String_Node_Str");
  Uri filterUri=Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,Uri.encode("String_Node_Str"));
  values.clear();
  values.put(Contacts._ID,contactId);
  values.put(SearchSnippetColumns.SNIPPET,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  assertStoredValues(filterUri,values);
}
Program: 152468
Project: 152468
Buggy source:
public void testForwardingToLocalInvisibleContacts(){
  long contactId1=queryContactId(createRawContactWithName("String_Node_Str","String_Node_Str"));
  Account account=new Account("String_Node_Str","String_Node_Str");
  long groupId=createGroup(account,"String_Node_Str","String_Node_Str",0,true,false);
  long contactId2=queryContactId(createRawContactWithName("String_Node_Str","String_Node_Str",account));
  Uri contentUri=Contacts.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,String.valueOf(Directory.LOCAL_INVISIBLE)).build();
  Cursor cursor=mResolver.query(contentUri,new String[]{Contacts._ID,Contacts.DISPLAY_NAME},null,null,null);
  assertEquals(0,cursor.getCount());
  cursor.close();
  mResolver.delete(Data.CONTENT_URI,Data.MIMETYPE + "String_Node_Str" + GroupMembership.GROUP_ROW_ID+ "String_Node_Str",new String[]{GroupMembership.CONTENT_ITEM_TYPE,String.valueOf(groupId)});
  cursor=mResolver.query(contentUri,new String[]{Contacts._ID,Contacts.DISPLAY_NAME},null,null,null);
  assertNotNull(cursor);
  assertEquals(1,cursor.getCount());
  cursor.moveToFirst();
  assertEquals(contactId2,cursor.getLong(0));
  assertEquals("String_Node_Str",cursor.getString(1));
  cursor.close();
  Uri filterUri=Contacts.CONTENT_FILTER_URI.buildUpon().appendEncodedPath("String_Node_Str").appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,String.valueOf(Directory.LOCAL_INVISIBLE)).build();
  cursor=mResolver.query(filterUri,new String[]{Contacts._ID,Contacts.DISPLAY_NAME},null,null,null);
  assertNotNull(cursor);
  assertEquals(1,cursor.getCount());
  cursor.moveToFirst();
  assertEquals(contactId2,cursor.getLong(0));
  assertEquals("String_Node_Str",cursor.getString(1));
  cursor.close();
}

Fixed version (ground truth):
public void testForwardingToLocalInvisibleContacts(){
  long contactId1=queryContactId(createRawContactWithName("String_Node_Str","String_Node_Str"));
  Account account=new Account("String_Node_Str","String_Node_Str");
  long groupId=createGroup(account,"String_Node_Str","String_Node_Str",0,true,false);
  long contactId2=queryContactId(createRawContactWithName("String_Node_Str","String_Node_Str",account));
  Uri contentUri=Contacts.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,String.valueOf(Directory.LOCAL_INVISIBLE)).build();
  Cursor cursor=mResolver.query(contentUri,new String[]{Contacts._ID,Contacts.DISPLAY_NAME},null,null,null);
  assertEquals(0,cursor.getCount());
  cursor.close();
  mResolver.delete(Data.CONTENT_URI,Data.MIMETYPE + "String_Node_Str" + GroupMembership.GROUP_ROW_ID+ "String_Node_Str",new String[]{GroupMembership.CONTENT_ITEM_TYPE,String.valueOf(groupId)});
  cursor=mResolver.query(contentUri,new String[]{Contacts._ID,Contacts.DISPLAY_NAME},null,null,null);
  assertNotNull(cursor);
  assertEquals(1,cursor.getCount());
  cursor.moveToFirst();
  assertEquals(contactId2,cursor.getLong(0));
  assertEquals("String_Node_Str",cursor.getString(1));
  cursor.close();
}
Program: 152470
Project: 152470
Buggy source:
/** 
 * Finds matching contacts and returns a cursor on those.
 */
public Cursor queryAggregationSuggestions(SQLiteQueryBuilder qb,String[] projection,long contactId,int maxSuggestions,String filter,ArrayList<AggregationSuggestionParameter> parameters){
  final SQLiteDatabase db=mDbHelper.getReadableDatabase();
  List<MatchScore> bestMatches=findMatchingContacts(db,contactId,parameters);
  return queryMatchingContacts(qb,db,contactId,projection,bestMatches,maxSuggestions,filter);
}

Fixed version (ground truth):
/** 
 * Finds matching contacts and returns a cursor on those.
 */
public Cursor queryAggregationSuggestions(SQLiteQueryBuilder qb,String[] projection,long contactId,int maxSuggestions,String filter,ArrayList<AggregationSuggestionParameter> parameters){
  final SQLiteDatabase db=mDbHelper.getReadableDatabase();
  db.beginTransaction();
  try {
    List<MatchScore> bestMatches=findMatchingContacts(db,contactId,parameters);
    return queryMatchingContacts(qb,db,projection,bestMatches,maxSuggestions,filter);
  }
  finally {
    db.endTransaction();
  }
}
Program: 152472
Project: 152472
Buggy source:
/** 
 * Finds matching contacts and returns a cursor on those.
 */
public Cursor queryAggregationSuggestions(SQLiteQueryBuilder qb,String[] projection,long contactId,int maxSuggestions,String filter,ArrayList<AggregationSuggestionParameter> parameters){
  final SQLiteDatabase db=mDbHelper.getReadableDatabase();
  List<MatchScore> bestMatches=findMatchingContacts(db,contactId,parameters);
  return queryMatchingContacts(qb,db,contactId,projection,bestMatches,maxSuggestions,filter);
}

Fixed version (ground truth):
/** 
 * Finds matching contacts and returns a cursor on those.
 */
public Cursor queryAggregationSuggestions(SQLiteQueryBuilder qb,String[] projection,long contactId,int maxSuggestions,String filter,ArrayList<AggregationSuggestionParameter> parameters){
  final SQLiteDatabase db=mDbHelper.getReadableDatabase();
  db.beginTransaction();
  try {
    List<MatchScore> bestMatches=findMatchingContacts(db,contactId,parameters);
    return queryMatchingContacts(qb,db,projection,bestMatches,maxSuggestions,filter);
  }
  finally {
    db.endTransaction();
  }
}
Program: 152474
Project: 152474
Buggy source:
/** 
 * Finds matching contacts and returns a cursor on those.
 */
public Cursor queryAggregationSuggestions(SQLiteQueryBuilder qb,String[] projection,long contactId,int maxSuggestions,String filter,ArrayList<AggregationSuggestionParameter> parameters){
  final SQLiteDatabase db=mDbHelper.getReadableDatabase();
  List<MatchScore> bestMatches=findMatchingContacts(db,contactId,parameters);
  return queryMatchingContacts(qb,db,contactId,projection,bestMatches,maxSuggestions,filter);
}

Fixed version (ground truth):
/** 
 * Finds matching contacts and returns a cursor on those.
 */
public Cursor queryAggregationSuggestions(SQLiteQueryBuilder qb,String[] projection,long contactId,int maxSuggestions,String filter,ArrayList<AggregationSuggestionParameter> parameters){
  final SQLiteDatabase db=mDbHelper.getReadableDatabase();
  db.beginTransaction();
  try {
    List<MatchScore> bestMatches=findMatchingContacts(db,contactId,parameters);
    return queryMatchingContacts(qb,db,projection,bestMatches,maxSuggestions,filter);
  }
  finally {
    db.endTransaction();
  }
}
Program: 152475
Project: 152475
Buggy source:
@Override public void setUp() throws Exception {
  super.setUp();
  mProvider=(ContactsProvider2)getProvider();
  mDirectoryManager=mProvider.getContactDirectoryManager();
  mPackageManager=(ContactsMockPackageManager)getProvider().getContext().getPackageManager();
}

Fixed version (ground truth):
@Override public void setUp() throws Exception {
  super.setUp();
  mProvider=(ContactsProvider2)getProvider();
  mDirectoryManager=mProvider.getContactDirectoryManagerForTest();
  mPackageManager=(ContactsMockPackageManager)getProvider().getContext().getPackageManager();
}
Program: 152476
Project: 152476
Buggy source:
@Override public void wipeData(){
  super.wipeData();
  SQLiteDatabase db=getDatabaseHelper().getWritableDatabase();
  db.execSQL("String_Node_Str");
  db.execSQL("String_Node_Str");
  db.execSQL("String_Node_Str");
  getContactDirectoryManager().scanAllPackages();
}

Fixed version (ground truth):
@Override public void wipeData(){
  super.wipeData();
  SQLiteDatabase db=getDatabaseHelper().getWritableDatabase();
  db.execSQL("String_Node_Str");
  db.execSQL("String_Node_Str");
  db.execSQL("String_Node_Str");
  getContactDirectoryManagerForTest().scanAllPackages();
}
Program: 152478
Project: 152478
Buggy source:
/** 
 * Creates a stand-alone Contact for the given raw contact ID.
 */
private void createNewContactForRawContact(SQLiteDatabase db,long rawContactId){
  mSelectionArgs1[0]=String.valueOf(rawContactId);
  computeAggregateData(db,mRawContactsQueryByRawContactId,mSelectionArgs1,mContactInsert);
  long contactId=mContactInsert.executeInsert();
  setContactIdAndMarkAggregated(rawContactId,contactId);
  mDbHelper.updateContactVisible(contactId);
  setPresenceContactId(rawContactId,contactId);
  updateAggregatedPresence(contactId);
}

Fixed version (ground truth):
/** 
 * Creates a stand-alone Contact for the given raw contact ID.
 */
private void createNewContactForRawContact(SQLiteDatabase db,long rawContactId){
  mSelectionArgs1[0]=String.valueOf(rawContactId);
  computeAggregateData(db,mRawContactsQueryByRawContactId,mSelectionArgs1,mContactInsert);
  long contactId=mContactInsert.executeInsert();
  setContactIdAndMarkAggregated(rawContactId,contactId);
  mDbHelper.updateContactVisible(contactId);
  setPresenceContactId(rawContactId,contactId);
  updateAggregatedStatusUpdate(contactId);
}
Program: 152479
Project: 152479
Buggy source:
public void updateAggregateData(long contactId){
  if (!mEnabled) {
    return;
  }
  final SQLiteDatabase db=mDbHelper.getWritableDatabase();
  computeAggregateData(db,contactId,mContactUpdate);
  mContactUpdate.bindLong(ContactReplaceSqlStatement.CONTACT_ID,contactId);
  mContactUpdate.execute();
  mDbHelper.updateContactVisible(contactId);
  updateAggregatedPresence(contactId);
}

Fixed version (ground truth):
public void updateAggregateData(long contactId){
  if (!mEnabled) {
    return;
  }
  final SQLiteDatabase db=mDbHelper.getWritableDatabase();
  computeAggregateData(db,contactId,mContactUpdate);
  mContactUpdate.bindLong(ContactReplaceSqlStatement.CONTACT_ID,contactId);
  mContactUpdate.execute();
  mDbHelper.updateContactVisible(contactId);
  updateAggregatedStatusUpdate(contactId);
}
Program: 152482
Project: 152482
Buggy source:
protected Uri insertStatusUpdate(int protocol,String customProtocol,String handle,int presence,String status,long timestamp,int chatMode){
  ContentValues values=new ContentValues();
  values.put(StatusUpdates.PROTOCOL,protocol);
  values.put(StatusUpdates.CUSTOM_PROTOCOL,customProtocol);
  values.put(StatusUpdates.IM_HANDLE,handle);
  if (presence != 0) {
    values.put(StatusUpdates.PRESENCE,presence);
    values.put(StatusUpdates.CHAT_CAPABILITY,chatMode);
  }
  if (status != null) {
    values.put(StatusUpdates.STATUS,status);
  }
  if (timestamp != 0) {
    values.put(StatusUpdates.STATUS_TIMESTAMP,timestamp);
  }
  Uri resultUri=mResolver.insert(StatusUpdates.CONTENT_URI,values);
  return resultUri;
}

Fixed version (ground truth):
private Uri insertStatusUpdate(ContentValues values,int presence,String status,long timestamp,int chatMode){
  if (presence != 0) {
    values.put(StatusUpdates.PRESENCE,presence);
    values.put(StatusUpdates.CHAT_CAPABILITY,chatMode);
  }
  if (status != null) {
    values.put(StatusUpdates.STATUS,status);
  }
  if (timestamp != 0) {
    values.put(StatusUpdates.STATUS_TIMESTAMP,timestamp);
  }
  Uri resultUri=mResolver.insert(StatusUpdates.CONTENT_URI,values);
  return resultUri;
}
Program: 152484
Project: 152484
Buggy source:
private void insertEmail(Cursor c,SQLiteStatement insert){
  long personId=c.getLong(ContactMethodsQuery.PERSON);
  String email=c.getString(ContactMethodsQuery.DATA);
  insert.bindLong(EmailInsert.RAW_CONTACT_ID,personId);
  insert.bindLong(EmailInsert.MIMETYPE_ID,mEmailMimetypeId);
  bindString(insert,EmailInsert.IS_PRIMARY,c.getString(ContactMethodsQuery.ISPRIMARY));
  bindString(insert,EmailInsert.DATA,email);
  bindString(insert,EmailInsert.AUX_DATA,c.getString(ContactMethodsQuery.AUX_DATA));
  bindString(insert,EmailInsert.TYPE,c.getString(ContactMethodsQuery.TYPE));
  bindString(insert,EmailInsert.LABEL,c.getString(ContactMethodsQuery.LABEL));
  long dataId=insert(insert);
  mContactsProvider.insertNameLookupForEmail(personId,dataId,email);
}

Fixed version (ground truth):
private void insertEmail(Cursor c,SQLiteStatement insert){
  long personId=c.getLong(ContactMethodsQuery.PERSON);
  String email=c.getString(ContactMethodsQuery.DATA);
  insert.bindLong(EmailInsert.RAW_CONTACT_ID,personId);
  insert.bindLong(EmailInsert.MIMETYPE_ID,mEmailMimetypeId);
  bindString(insert,EmailInsert.IS_PRIMARY,c.getString(ContactMethodsQuery.ISPRIMARY));
  bindString(insert,EmailInsert.IS_SUPER_PRIMARY,c.getString(ContactMethodsQuery.ISPRIMARY));
  bindString(insert,EmailInsert.DATA,email);
  bindString(insert,EmailInsert.AUX_DATA,c.getString(ContactMethodsQuery.AUX_DATA));
  bindString(insert,EmailInsert.TYPE,c.getString(ContactMethodsQuery.TYPE));
  bindString(insert,EmailInsert.LABEL,c.getString(ContactMethodsQuery.LABEL));
  long dataId=insert(insert);
  mContactsProvider.insertNameLookupForEmail(personId,dataId,email);
}