nus-yam/ex-repair huggingface dataset:
Program: 152398
Project: 152398
Buggy source:
/** 
 * Find out which mime-types are shared by more than one contacts for   {@code rawContactIds}. Clear the is_super_primary settings for these mime-types.  {@code rawContactIds} should be a comma separated ID list.
 */
private void clearSuperPrimarySetting(SQLiteDatabase db,String rawContactIds){
  final String sql="String_Node_Str" + DataColumns.MIMETYPE_ID + "String_Node_Str"+ RawContacts.CONTACT_ID+ "String_Node_Str"+ Tables.DATA+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ RawContacts._ID+ "String_Node_Str"+ Data.IS_SUPER_PRIMARY+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ rawContactIds+ "String_Node_Str"+ DataColumns.MIMETYPE_ID+ "String_Node_Str";
  int index=0;
  final StringBuilder mimeTypeCondition=new StringBuilder();
  mimeTypeCondition.append("String_Node_Str" + DataColumns.MIMETYPE_ID + "String_Node_Str");
  final Cursor c=db.rawQuery(sql,null);
  try {
    c.moveToPosition(-1);
    while (c.moveToNext()) {
      if (index > 0) {
        mimeTypeCondition.append(',');
      }
      mimeTypeCondition.append(c.getLong((0)));
      index++;
    }
  }
  finally {
    c.close();
  }
  if (index == 0) {
    return;
  }
  String superPrimaryUpdateSql="String_Node_Str" + Tables.DATA + "String_Node_Str"+ Data.IS_SUPER_PRIMARY+ "String_Node_Str"+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ RawContacts._ID+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ rawContactIds+ "String_Node_Str";
  mimeTypeCondition.append(')');
  superPrimaryUpdateSql+=mimeTypeCondition.toString();
  db.execSQL(superPrimaryUpdateSql,null);
}

Fixed version (ground truth):
/** 
 * Find out which mime-types are shared by more than one contacts for   {@code rawContactIds}. Clear the is_super_primary settings for these mime-types.  {@code rawContactIds} should be a comma separated ID list.
 */
private void clearSuperPrimarySetting(SQLiteDatabase db,String rawContactIds){
  final String sql="String_Node_Str" + DataColumns.MIMETYPE_ID + "String_Node_Str"+ Tables.DATA+ "String_Node_Str"+ Data.IS_SUPER_PRIMARY+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ rawContactIds+ "String_Node_Str"+ DataColumns.MIMETYPE_ID+ "String_Node_Str";
  int index=0;
  final StringBuilder mimeTypeCondition=new StringBuilder();
  mimeTypeCondition.append("String_Node_Str" + DataColumns.MIMETYPE_ID + "String_Node_Str");
  final Cursor c=db.rawQuery(sql,null);
  try {
    c.moveToPosition(-1);
    while (c.moveToNext()) {
      if (index > 0) {
        mimeTypeCondition.append(',');
      }
      mimeTypeCondition.append(c.getLong((0)));
      index++;
    }
  }
  finally {
    c.close();
  }
  if (index == 0) {
    return;
  }
  String superPrimaryUpdateSql="String_Node_Str" + Tables.DATA + "String_Node_Str"+ Data.IS_SUPER_PRIMARY+ "String_Node_Str"+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ rawContactIds+ "String_Node_Str";
  mimeTypeCondition.append(')');
  superPrimaryUpdateSql+=mimeTypeCondition.toString();
  db.execSQL(superPrimaryUpdateSql);
}
Program: 152399
Project: 152399
Buggy source:
/** 
 * Find the set of matching raw contacts for given rawContactId. Add all the raw contact candidates with matching scores > threshold to RawContactMatchingCandidates. Keep doing this for every raw contact in RawContactMatchingCandidates until is it not changing.
 */
private RawContactMatchingCandidates findRawContactMatchingCandidates(SQLiteDatabase db,long rawContactId,MatchCandidateList candidates,RawContactMatcher matcher){
  updateMatchScoresForSuggestionsBasedOnDataMatches(db,rawContactId,candidates,matcher);
  final RawContactMatchingCandidates matchingCandidates=new RawContactMatchingCandidates(matcher.pickBestMatches(SCORE_THRESHOLD_SUGGEST));
  Set<Long> newIds=new HashSet<>();
  newIds.addAll(matchingCandidates.getRawContactIdSet());
  while (!newIds.isEmpty()) {
    final Set<Long> tmpIdSet=new HashSet<>();
    for (    long rId : newIds) {
      final RawContactMatcher rMatcher=new RawContactMatcher();
      updateMatchScoresForSuggestionsBasedOnDataMatches(db,rId,new MatchCandidateList(),rMatcher);
      List<MatchScore> newMatches=rMatcher.pickBestMatches(SCORE_THRESHOLD_SUGGEST);
      for (      MatchScore newMatch : newMatches) {
        final long newRawContactId=newMatch.getRawContactId();
        if (!matchingCandidates.getRawContactIdSet().contains(newRawContactId)) {
          tmpIdSet.add(newRawContactId);
          matchingCandidates.add(newMatch);
        }
      }
    }
    newIds.clear();
    newIds.addAll(tmpIdSet);
  }
  return matchingCandidates;
}

Fixed version (ground truth):
/** 
 * Find the set of matching raw contacts for given rawContactId. Add all the raw contact candidates with matching scores > threshold to RawContactMatchingCandidates. Keep doing this for every raw contact in RawContactMatchingCandidates until is it not changing.
 */
private RawContactMatchingCandidates findRawContactMatchingCandidates(SQLiteDatabase db,long rawContactId,MatchCandidateList candidates,RawContactMatcher matcher){
  updateMatchScores(db,rawContactId,candidates,matcher);
  final RawContactMatchingCandidates matchingCandidates=new RawContactMatchingCandidates(matcher.pickBestMatches());
  Set<Long> newIds=new HashSet<>();
  newIds.addAll(matchingCandidates.getRawContactIdSet());
  while (!newIds.isEmpty()) {
    final Set<Long> tmpIdSet=new HashSet<>();
    for (    long rId : newIds) {
      final RawContactMatcher rMatcher=new RawContactMatcher();
      updateMatchScores(db,rId,new MatchCandidateList(),rMatcher);
      List<MatchScore> newMatches=rMatcher.pickBestMatches();
      for (      MatchScore newMatch : newMatches) {
        final long newRawContactId=newMatch.getRawContactId();
        if (!matchingCandidates.getRawContactIdSet().contains(newRawContactId)) {
          tmpIdSet.add(newRawContactId);
          matchingCandidates.add(newMatch);
        }
      }
    }
    newIds.clear();
    newIds.addAll(tmpIdSet);
  }
  return matchingCandidates;
}
Program: 152402
Project: 152402
Buggy source:
/** 
 * Find out which mime-types are shared by more than one contacts for   {@code rawContactIds}. Clear the is_super_primary settings for these mime-types.  {@code rawContactIds} should be a comma separated ID list.
 */
private void clearSuperPrimarySetting(SQLiteDatabase db,String rawContactIds){
  final String sql="String_Node_Str" + DataColumns.MIMETYPE_ID + "String_Node_Str"+ RawContacts.CONTACT_ID+ "String_Node_Str"+ Tables.DATA+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ RawContacts._ID+ "String_Node_Str"+ Data.IS_SUPER_PRIMARY+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ rawContactIds+ "String_Node_Str"+ DataColumns.MIMETYPE_ID+ "String_Node_Str";
  int index=0;
  final StringBuilder mimeTypeCondition=new StringBuilder();
  mimeTypeCondition.append("String_Node_Str" + DataColumns.MIMETYPE_ID + "String_Node_Str");
  final Cursor c=db.rawQuery(sql,null);
  try {
    c.moveToPosition(-1);
    while (c.moveToNext()) {
      if (index > 0) {
        mimeTypeCondition.append(',');
      }
      mimeTypeCondition.append(c.getLong((0)));
      index++;
    }
  }
  finally {
    c.close();
  }
  if (index == 0) {
    return;
  }
  String superPrimaryUpdateSql="String_Node_Str" + Tables.DATA + "String_Node_Str"+ Data.IS_SUPER_PRIMARY+ "String_Node_Str"+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ RawContacts._ID+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ rawContactIds+ "String_Node_Str";
  mimeTypeCondition.append(')');
  superPrimaryUpdateSql+=mimeTypeCondition.toString();
  db.execSQL(superPrimaryUpdateSql,null);
}

Fixed version (ground truth):
/** 
 * Find out which mime-types are shared by more than one contacts for   {@code rawContactIds}. Clear the is_super_primary settings for these mime-types.  {@code rawContactIds} should be a comma separated ID list.
 */
private void clearSuperPrimarySetting(SQLiteDatabase db,String rawContactIds){
  final String sql="String_Node_Str" + DataColumns.MIMETYPE_ID + "String_Node_Str"+ Tables.DATA+ "String_Node_Str"+ Data.IS_SUPER_PRIMARY+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ rawContactIds+ "String_Node_Str"+ DataColumns.MIMETYPE_ID+ "String_Node_Str";
  int index=0;
  final StringBuilder mimeTypeCondition=new StringBuilder();
  mimeTypeCondition.append("String_Node_Str" + DataColumns.MIMETYPE_ID + "String_Node_Str");
  final Cursor c=db.rawQuery(sql,null);
  try {
    c.moveToPosition(-1);
    while (c.moveToNext()) {
      if (index > 0) {
        mimeTypeCondition.append(',');
      }
      mimeTypeCondition.append(c.getLong((0)));
      index++;
    }
  }
  finally {
    c.close();
  }
  if (index == 0) {
    return;
  }
  String superPrimaryUpdateSql="String_Node_Str" + Tables.DATA + "String_Node_Str"+ Data.IS_SUPER_PRIMARY+ "String_Node_Str"+ "String_Node_Str"+ Data.RAW_CONTACT_ID+ "String_Node_Str"+ rawContactIds+ "String_Node_Str";
  mimeTypeCondition.append(')');
  superPrimaryUpdateSql+=mimeTypeCondition.toString();
  db.execSQL(superPrimaryUpdateSql);
}
Program: 152403
Project: 152403
Buggy source:
/** 
 * Find the set of matching raw contacts for given rawContactId. Add all the raw contact candidates with matching scores > threshold to RawContactMatchingCandidates. Keep doing this for every raw contact in RawContactMatchingCandidates until is it not changing.
 */
private RawContactMatchingCandidates findRawContactMatchingCandidates(SQLiteDatabase db,long rawContactId,MatchCandidateList candidates,RawContactMatcher matcher){
  updateMatchScoresForSuggestionsBasedOnDataMatches(db,rawContactId,candidates,matcher);
  final RawContactMatchingCandidates matchingCandidates=new RawContactMatchingCandidates(matcher.pickBestMatches(SCORE_THRESHOLD_SUGGEST));
  Set<Long> newIds=matchingCandidates.getRawContactIdSet();
  while (!newIds.isEmpty()) {
    final Set<Long> tmpIdSet=new HashSet<>();
    for (    long rId : newIds) {
      final RawContactMatcher rMatcher=new RawContactMatcher();
      updateMatchScoresForSuggestionsBasedOnDataMatches(db,rId,new MatchCandidateList(),rMatcher);
      List<MatchScore> newMatches=rMatcher.pickBestMatches(SCORE_THRESHOLD_SUGGEST);
      for (      MatchScore newMatch : newMatches) {
        final long newRawContactId=newMatch.getRawContactId();
        if (!matchingCandidates.getRawContactIdSet().contains(newRawContactId)) {
          tmpIdSet.add(newRawContactId);
          matchingCandidates.add(newMatch);
        }
      }
    }
    newIds=tmpIdSet;
  }
  return matchingCandidates;
}

Fixed version (ground truth):
/** 
 * Find the set of matching raw contacts for given rawContactId. Add all the raw contact candidates with matching scores > threshold to RawContactMatchingCandidates. Keep doing this for every raw contact in RawContactMatchingCandidates until is it not changing.
 */
private RawContactMatchingCandidates findRawContactMatchingCandidates(SQLiteDatabase db,long rawContactId,MatchCandidateList candidates,RawContactMatcher matcher){
  updateMatchScoresForSuggestionsBasedOnDataMatches(db,rawContactId,candidates,matcher);
  final RawContactMatchingCandidates matchingCandidates=new RawContactMatchingCandidates(matcher.pickBestMatches(SCORE_THRESHOLD_SUGGEST));
  Set<Long> newIds=new HashSet<>();
  newIds.addAll(matchingCandidates.getRawContactIdSet());
  while (!newIds.isEmpty()) {
    final Set<Long> tmpIdSet=new HashSet<>();
    for (    long rId : newIds) {
      final RawContactMatcher rMatcher=new RawContactMatcher();
      updateMatchScoresForSuggestionsBasedOnDataMatches(db,rId,new MatchCandidateList(),rMatcher);
      List<MatchScore> newMatches=rMatcher.pickBestMatches(SCORE_THRESHOLD_SUGGEST);
      for (      MatchScore newMatch : newMatches) {
        final long newRawContactId=newMatch.getRawContactId();
        if (!matchingCandidates.getRawContactIdSet().contains(newRawContactId)) {
          tmpIdSet.add(newRawContactId);
          matchingCandidates.add(newMatch);
        }
      }
    }
    newIds.clear();
    newIds.addAll(tmpIdSet);
  }
  return matchingCandidates;
}
Program: 152404
Project: 152404
Buggy source:
/** 
 * Compute hash_id column and add it to values. If both of data1 and data2 changed, using new values to compute hash_id. If one of data1 and data2 changed, read another one from DB and compute hash_id. If both data1 and data2 are null, use data15 to compute hash_id.
 */
private void handleHashIdForUpdate(ContentValues values,long dataId){
  String data1=values.getAsString(Data.DATA1);
  String data2=values.getAsString(Data.DATA2);
  byte[] data15=values.getAsByteArray(Data.DATA15);
  if (values.containsKey(Data.DATA1) || values.containsKey(Data.DATA2) || values.containsKey(Data.DATA15)) {
    mSelectionArgs1[0]=String.valueOf(dataId);
    final Cursor c=mDbHelper.getReadableDatabase().query(Tables.DATA,HASH_INPUT_COLUMNS,Data._ID + "String_Node_Str",mSelectionArgs1,null,null,null);
    try {
      if (c.moveToFirst()) {
        data1=values.containsKey(Data.DATA1) ? data1 : c.getString(0);
        data2=values.containsKey(Data.DATA2) ? data2 : c.getString(1);
        data15=values.containsKey(Data.DATA15) ? data15 : c.getBlob(2);
      }
    }
  finally {
      c.close();
    }
  }
  final String hashId=mDbHelper.generateHashId(data1,data2,data15);
  if (TextUtils.isEmpty(hashId)) {
    values.putNull(Data.HASH_ID);
  }
 else {
    values.put(Data.HASH_ID,hashId);
  }
}

Fixed version (ground truth):
/** 
 * Compute hash_id column and add it to values. If both of data1 and data2 changed, using new values to compute hash_id. If one of data1 and data2 changed, read another one from DB and compute hash_id. If both data1 and data2 are null, use data15 to compute hash_id.
 */
private void handleHashIdForUpdate(ContentValues values,long dataId){
  if (values.containsKey(Data.DATA1) || values.containsKey(Data.DATA2) || values.containsKey(Data.DATA15)) {
    String data1=values.getAsString(Data.DATA1);
    String data2=values.getAsString(Data.DATA2);
    byte[] data15=values.getAsByteArray(Data.DATA15);
    mSelectionArgs1[0]=String.valueOf(dataId);
    final Cursor c=mDbHelper.getReadableDatabase().query(Tables.DATA,HASH_INPUT_COLUMNS,Data._ID + "String_Node_Str",mSelectionArgs1,null,null,null);
    try {
      if (c.moveToFirst()) {
        data1=values.containsKey(Data.DATA1) ? data1 : c.getString(0);
        data2=values.containsKey(Data.DATA2) ? data2 : c.getString(1);
        data15=values.containsKey(Data.DATA15) ? data15 : c.getBlob(2);
      }
    }
  finally {
      c.close();
    }
    final String hashId=mDbHelper.generateHashId(data1,data2,data15);
    if (TextUtils.isEmpty(hashId)) {
      values.putNull(Data.HASH_ID);
    }
 else {
      values.put(Data.HASH_ID,hashId);
    }
  }
}
Program: 152406
Project: 152406
Buggy source:
/** 
 * Build a sql to update the last updated timestamp for contacts.
 * @param rawContactIds The raw contact ids that contacts should be updated for.
 * @return The update sql statement.
 */
private static String buildUpdateLastUpdateSql(Set<Long> rawContactIds){
  final String bindSql=MoreDatabaseUtils.buildBindArgString(rawContactIds.size());
  final String sql="String_Node_Str" + Tables.CONTACTS + "String_Node_Str"+ Contacts.CONTACT_LAST_UPDATED_TIMESTAMP+ "String_Node_Str"+ Clock.getInstance().currentTimeMillis()+ "String_Node_Str"+ Contacts._ID+ "String_Node_Str"+ "String_Node_Str"+ ContactsContract.RawContacts.CONTACT_ID+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ ContactsContract.RawContacts._ID+ "String_Node_Str"+ bindSql+ "String_Node_Str"+ "String_Node_Str";
  return sql;
}

Fixed version (ground truth):
/** 
 * Build a sql to update the last updated timestamp for contacts.
 * @param rawContactIds The raw contact ids that contacts should be updated for.
 * @return The update sql statement.
 */
private static String buildUpdateLastUpdateSql(Set<Long> rawContactIds){
  final String sql="String_Node_Str" + Tables.CONTACTS + "String_Node_Str"+ Contacts.CONTACT_LAST_UPDATED_TIMESTAMP+ "String_Node_Str"+ Clock.getInstance().currentTimeMillis()+ "String_Node_Str"+ Contacts._ID+ "String_Node_Str"+ "String_Node_Str"+ ContactsContract.RawContacts.CONTACT_ID+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ ContactsContract.RawContacts._ID+ "String_Node_Str"+ TextUtils.join("String_Node_Str",rawContactIds)+ "String_Node_Str"+ "String_Node_Str";
  return sql;
}
Program: 152407
Project: 152407
Buggy source:
/** 
 * Refreshes the last updated timestamp of the contact with the current time.
 * @param db The sqlite database instance.
 * @param rawContactIds A set of raw contacts ids to refresh the contact for.
 */
public static void updateContactLastUpdate(SQLiteDatabase db,Set<Long> rawContactIds){
  if (rawContactIds.isEmpty()) {
    return;
  }
  final Long[] bindArgs=rawContactIds.toArray(new Long[rawContactIds.size()]);
  db.execSQL(buildUpdateLastUpdateSql(rawContactIds),bindArgs);
}

Fixed version (ground truth):
/** 
 * Refreshes the last updated timestamp of the contact with the current time.
 * @param db The sqlite database instance.
 * @param rawContactIds A set of raw contacts ids to refresh the contact for.
 */
public static void updateContactLastUpdate(SQLiteDatabase db,Set<Long> rawContactIds){
  if (rawContactIds.isEmpty()) {
    return;
  }
  db.execSQL(buildUpdateLastUpdateSql(rawContactIds));
}
Program: 152408
Project: 152408
Buggy source:
/** 
 * Build a bind arg where clause. <p> e.g. Calling this method with value of 4 results in: <p> "?,?,?,?"
 * @param numArgs The number of arguments.
 * @return A string that can be used for bind args in a sql where clause.
 */
public static String buildBindArgString(int numArgs){
  final StringBuilder sb=new StringBuilder();
  String delimiter="String_Node_Str";
  for (int i=0; i < numArgs; i++) {
    sb.append(delimiter).append("String_Node_Str");
    delimiter="String_Node_Str";
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Build a bind arg where clause. <p> e.g. Calling this method with value of 4 results in: <p> "?,?,?,?"
 * @param numArgs The number of arguments.
 * @return A string that can be used for bind args in a sql where clause.
 */
@NeededForTesting public static String buildBindArgString(int numArgs){
  final StringBuilder sb=new StringBuilder();
  String delimiter="String_Node_Str";
  for (int i=0; i < numArgs; i++) {
    sb.append(delimiter).append("String_Node_Str");
    delimiter="String_Node_Str";
  }
  return sb.toString();
}
Program: 152409
Project: 152409
Buggy source:
/** 
 * Builds a DROP INDEX ddl statement for a given table and field.
 * @param table The table name that was originally used to create the index.
 * @param field The field that was originally used to create the index.
 * @return The drop index sql statement.
 */
public static String buildDropIndexSql(String table,String field){
  return "String_Node_Str" + buildIndexName(table,field);
}

Fixed version (ground truth):
/** 
 * Builds a DROP INDEX ddl statement for a given table and field.
 * @param table The table name that was originally used to create the index.
 * @param field The field that was originally used to create the index.
 * @return The drop index sql statement.
 */
@NeededForTesting public static String buildDropIndexSql(String table,String field){
  return "String_Node_Str" + buildIndexName(table,field);
}
Program: 152412
Project: 152412
Buggy source:
/** 
 * Build a bind arg where clause. <p> e.g. Calling this method with value of 4 results in: <p> "?,?,?,?"
 * @param numArgs The number of arguments.
 * @return A string that can be used for bind args in a sql where clause.
 */
public static String buildBindArgString(int numArgs){
  final StringBuilder sb=new StringBuilder();
  String delimiter="String_Node_Str";
  for (int i=0; i < numArgs; i++) {
    sb.append(delimiter).append("String_Node_Str");
    delimiter="String_Node_Str";
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Build a bind arg where clause. <p> e.g. Calling this method with value of 4 results in: <p> "?,?,?,?"
 * @param numArgs The number of arguments.
 * @return A string that can be used for bind args in a sql where clause.
 */
@NeededForTesting public static String buildBindArgString(int numArgs){
  final StringBuilder sb=new StringBuilder();
  String delimiter="String_Node_Str";
  for (int i=0; i < numArgs; i++) {
    sb.append(delimiter).append("String_Node_Str");
    delimiter="String_Node_Str";
  }
  return sb.toString();
}
Program: 152413
Project: 152413
Buggy source:
/** 
 * Builds a DROP INDEX ddl statement for a given table and field.
 * @param table The table name that was originally used to create the index.
 * @param field The field that was originally used to create the index.
 * @return The drop index sql statement.
 */
public static String buildDropIndexSql(String table,String field){
  return "String_Node_Str" + buildIndexName(table,field);
}

Fixed version (ground truth):
/** 
 * Builds a DROP INDEX ddl statement for a given table and field.
 * @param table The table name that was originally used to create the index.
 * @param field The field that was originally used to create the index.
 * @return The drop index sql statement.
 */
@NeededForTesting public static String buildDropIndexSql(String table,String field){
  return "String_Node_Str" + buildIndexName(table,field);
}
Program: 152414
Project: 152414
Buggy source:
/** 
 * Build a sql to update the last updated timestamp for contacts.
 * @param rawContactIds The raw contact ids that contacts should be updated for.
 * @return The update sql statement.
 */
private static String buildUpdateLastUpdateSql(Set<Long> rawContactIds){
  final String bindSql=MoreDatabaseUtils.buildBindArgString(rawContactIds.size());
  final String sql="String_Node_Str" + Tables.CONTACTS + "String_Node_Str"+ Contacts.CONTACT_LAST_UPDATED_TIMESTAMP+ "String_Node_Str"+ Clock.getInstance().currentTimeMillis()+ "String_Node_Str"+ Contacts._ID+ "String_Node_Str"+ "String_Node_Str"+ ContactsContract.RawContacts.CONTACT_ID+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ ContactsContract.RawContacts._ID+ "String_Node_Str"+ bindSql+ "String_Node_Str"+ "String_Node_Str";
  return sql;
}

Fixed version (ground truth):
/** 
 * Build a sql to update the last updated timestamp for contacts.
 * @param rawContactIds The raw contact ids that contacts should be updated for.
 * @return The update sql statement.
 */
private static String buildUpdateLastUpdateSql(Set<Long> rawContactIds){
  final String sql="String_Node_Str" + Tables.CONTACTS + "String_Node_Str"+ Contacts.CONTACT_LAST_UPDATED_TIMESTAMP+ "String_Node_Str"+ Clock.getInstance().currentTimeMillis()+ "String_Node_Str"+ Contacts._ID+ "String_Node_Str"+ "String_Node_Str"+ ContactsContract.RawContacts.CONTACT_ID+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ ContactsContract.RawContacts._ID+ "String_Node_Str"+ TextUtils.join("String_Node_Str",rawContactIds)+ "String_Node_Str"+ "String_Node_Str";
  return sql;
}
Program: 152415
Project: 152415
Buggy source:
/** 
 * Refreshes the last updated timestamp of the contact with the current time.
 * @param db The sqlite database instance.
 * @param rawContactIds A set of raw contacts ids to refresh the contact for.
 */
public static void updateContactLastUpdate(SQLiteDatabase db,Set<Long> rawContactIds){
  if (rawContactIds.isEmpty()) {
    return;
  }
  final Long[] bindArgs=rawContactIds.toArray(new Long[rawContactIds.size()]);
  db.execSQL(buildUpdateLastUpdateSql(rawContactIds),bindArgs);
}

Fixed version (ground truth):
/** 
 * Refreshes the last updated timestamp of the contact with the current time.
 * @param db The sqlite database instance.
 * @param rawContactIds A set of raw contacts ids to refresh the contact for.
 */
public static void updateContactLastUpdate(SQLiteDatabase db,Set<Long> rawContactIds){
  if (rawContactIds.isEmpty()) {
    return;
  }
  db.execSQL(buildUpdateLastUpdateSql(rawContactIds));
}
Program: 152416
Project: 152416
Buggy source:
/** 
 * Build a bind arg where clause. <p> e.g. Calling this method with value of 4 results in: <p> "?,?,?,?"
 * @param numArgs The number of arguments.
 * @return A string that can be used for bind args in a sql where clause.
 */
public static String buildBindArgString(int numArgs){
  final StringBuilder sb=new StringBuilder();
  String delimiter="String_Node_Str";
  for (int i=0; i < numArgs; i++) {
    sb.append(delimiter).append("String_Node_Str");
    delimiter="String_Node_Str";
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Build a bind arg where clause. <p> e.g. Calling this method with value of 4 results in: <p> "?,?,?,?"
 * @param numArgs The number of arguments.
 * @return A string that can be used for bind args in a sql where clause.
 */
@NeededForTesting public static String buildBindArgString(int numArgs){
  final StringBuilder sb=new StringBuilder();
  String delimiter="String_Node_Str";
  for (int i=0; i < numArgs; i++) {
    sb.append(delimiter).append("String_Node_Str");
    delimiter="String_Node_Str";
  }
  return sb.toString();
}
Program: 152417
Project: 152417
Buggy source:
/** 
 * Builds a DROP INDEX ddl statement for a given table and field.
 * @param table The table name that was originally used to create the index.
 * @param field The field that was originally used to create the index.
 * @return The drop index sql statement.
 */
public static String buildDropIndexSql(String table,String field){
  return "String_Node_Str" + buildIndexName(table,field);
}

Fixed version (ground truth):
/** 
 * Builds a DROP INDEX ddl statement for a given table and field.
 * @param table The table name that was originally used to create the index.
 * @param field The field that was originally used to create the index.
 * @return The drop index sql statement.
 */
@NeededForTesting public static String buildDropIndexSql(String table,String field){
  return "String_Node_Str" + buildIndexName(table,field);
}
Program: 152425
Project: 152425
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: 152427
Project: 152427
Buggy source:
protected void assertCursorValues(Cursor cursor,ContentValues[] expectedValues){
  StringBuilder message=new StringBuilder();
  for (  ContentValues v : expectedValues) {
    boolean found=false;
    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
      found=equalsWithExpectedValues(cursor,v,message);
      if (found) {
        break;
      }
    }
    assertTrue("String_Node_Str" + v + message.toString(),found);
  }
}

Fixed version (ground truth):
protected void assertCursorValues(Cursor cursor,ContentValues[] expectedValues){
  StringBuilder message=new StringBuilder();
  final BitSet used=new BitSet(cursor.getCount());
  for (  ContentValues v : expectedValues) {
    boolean found=false;
    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
      final int pos=cursor.getPosition();
      if (used.get(pos))       continue;
      found=equalsWithExpectedValues(cursor,v,message);
      if (found) {
        used.set(pos);
        break;
      }
    }
    assertTrue("String_Node_Str" + v + message.toString(),found);
  }
}
Program: 152428
Project: 152428
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: 152429
Project: 152429
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: 152430
Project: 152430
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: 152432
Project: 152432
Buggy source:
protected void assertCursorValues(Cursor cursor,ContentValues[] expectedValues){
  StringBuilder message=new StringBuilder();
  for (  ContentValues v : expectedValues) {
    boolean found=false;
    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
      found=equalsWithExpectedValues(cursor,v,message);
      if (found) {
        break;
      }
    }
    assertTrue("String_Node_Str" + v + message.toString(),found);
  }
}

Fixed version (ground truth):
protected void assertCursorValues(Cursor cursor,ContentValues[] expectedValues){
  StringBuilder message=new StringBuilder();
  final BitSet used=new BitSet(cursor.getCount());
  for (  ContentValues v : expectedValues) {
    boolean found=false;
    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
      final int pos=cursor.getPosition();
      if (used.get(pos))       continue;
      found=equalsWithExpectedValues(cursor,v,message);
      if (found) {
        used.set(pos);
        break;
      }
    }
    assertTrue("String_Node_Str" + v + message.toString(),found);
  }
}
Program: 152433
Project: 152433
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: 152434
Project: 152434
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: 152436
Project: 152436
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: 152438
Project: 152438
Buggy source:
protected void assertCursorValues(Cursor cursor,ContentValues[] expectedValues){
  StringBuilder message=new StringBuilder();
  for (  ContentValues v : expectedValues) {
    boolean found=false;
    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
      found=equalsWithExpectedValues(cursor,v,message);
      if (found) {
        break;
      }
    }
    assertTrue("String_Node_Str" + v + message.toString(),found);
  }
}

Fixed version (ground truth):
protected void assertCursorValues(Cursor cursor,ContentValues[] expectedValues){
  StringBuilder message=new StringBuilder();
  final BitSet used=new BitSet(cursor.getCount());
  for (  ContentValues v : expectedValues) {
    boolean found=false;
    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
      final int pos=cursor.getPosition();
      if (used.get(pos))       continue;
      found=equalsWithExpectedValues(cursor,v,message);
      if (found) {
        used.set(pos);
        break;
      }
    }
    assertTrue("String_Node_Str" + v + message.toString(),found);
  }
}