Program: 171957
Project: 171957
Buggy source:
private synchronized int insertMessages(List<AVIMMessage> messages,boolean breakpoint){
  SQLiteDatabase db=dbHelper.getWritableDatabase();
  db.beginTransaction();
  int insertCount=0;
  for (  AVIMMessage message : messages) {
    ContentValues values=new ContentValues();
    values.put(COLUMN_CONVERSATION_ID,message.getConversationId());
    values.put(COLUMN_MESSAGE_ID,message.getMessageId());
    values.put(COLUMN_TIMESTAMP,message.getTimestamp());
    values.put(COLUMN_FROM_PEER_ID,message.getFrom());
    if (message instanceof AVIMBinaryMessage) {
      values.put(COLUMN_PAYLOAD,((AVIMBinaryMessage)message).getBytes());
      values.put(COLUMN_MSG_INNERTYPE,MESSAGE_INNERTYPE_BIN);
    }
 else {
      values.put(COLUMN_PAYLOAD,message.getContent().getBytes());
      values.put(COLUMN_MSG_INNERTYPE,MESSAGE_INNERTYPE_PLAIN);
    }
    values.put(COLUMN_MESSAGE_DELIVEREDAT,message.getDeliveredAt());
    values.put(COLUMN_MESSAGE_READAT,message.getReadAt());
    values.put(COLUMN_MESSAGE_UPDATEAT,message.getUpdateAt());
    values.put(COLUMN_STATUS,message.getMessageStatus().getStatusCode());
    values.put(COLUMN_BREAKPOINT,breakpoint ? 1 : 0);
    values.put(COLUMN_MSG_MENTION_ALL,message.isMentionAll() ? 1 : 0);
    values.put(COLUMN_MSG_MENTION_LIST,message.getMentionListString());
    try {
      long itemId=db.insertWithOnConflict(MESSAGE_TABLE,null,values,SQLiteDatabase.CONFLICT_IGNORE);
      boolean insert=itemId > -1;
      if (insert) {
        insertCount++;
      }
    }
 catch (    SQLException e) {
      if (AVOSCloud.isDebugLogEnabled()) {
        e.printStackTrace();
      }
    }
  }
  db.setTransactionSuccessful();
  db.endTransaction();
  return insertCount;
}

Fixed version (ground truth):
private synchronized int insertMessages(List<AVIMMessage> messages,boolean breakpoint){
  SQLiteDatabase db=dbHelper.getWritableDatabase();
  db.beginTransaction();
  int insertCount=0;
  for (  AVIMMessage message : messages) {
    ContentValues values=new ContentValues();
    values.put(COLUMN_CONVERSATION_ID,message.getConversationId());
    values.put(COLUMN_MESSAGE_ID,message.getMessageId());
    values.put(COLUMN_TIMESTAMP,message.getTimestamp());
    values.put(COLUMN_FROM_PEER_ID,message.getFrom());
    if (message instanceof AVIMBinaryMessage) {
      values.put(COLUMN_PAYLOAD,((AVIMBinaryMessage)message).getBytes());
      values.put(COLUMN_MSG_INNERTYPE,MESSAGE_INNERTYPE_BIN);
    }
 else {
      values.put(COLUMN_PAYLOAD,message.getContent().getBytes());
      values.put(COLUMN_MSG_INNERTYPE,MESSAGE_INNERTYPE_PLAIN);
    }
    values.put(COLUMN_MESSAGE_DELIVEREDAT,message.getDeliveredAt());
    values.put(COLUMN_MESSAGE_READAT,message.getReadAt());
    values.put(COLUMN_MESSAGE_UPDATEAT,message.getUpdateAt());
    values.put(COLUMN_STATUS,message.getMessageStatus().getStatusCode());
    values.put(COLUMN_BREAKPOINT,breakpoint ? 1 : 0);
    values.put(COLUMN_MSG_MENTION_ALL,message.isMentionAll() ? 1 : 0);
    values.put(COLUMN_MSG_MENTION_LIST,message.getMentionListString());
    try {
      long itemId=db.insertWithOnConflict(MESSAGE_TABLE,null,values,SQLiteDatabase.CONFLICT_REPLACE);
      boolean insert=itemId > -1;
      if (insert) {
        insertCount++;
      }
    }
 catch (    SQLException e) {
      if (AVOSCloud.isDebugLogEnabled()) {
        e.printStackTrace();
      }
    }
  }
  db.setTransactionSuccessful();
  db.endTransaction();
  return insertCount;
}