Program: 161478
Project: 161478
Buggy source:
private static void addEvents(Context c,Uri uri){
  if (ContextCompat.checkSelfPermission(c,Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
    return;
  }
  ContentResolver contentResolver=c.getContentResolver();
  String id="String_Node_Str";
  try (Cursor cursor=contentResolver.query(uri,PROJECTION,null,null,null)){
    while (cursor.moveToNext()) {
      id=cursor.getString(0);
    }
  }
   CalendarManager calendarManager=new CalendarManager(c);
  Date dtstart;
  Date dtend;
  try (Cursor cursor=calendarManager.getAllFromDb()){
    while (cursor.moveToNext()) {
      final String title=cursor.getString(3);
      final String description=cursor.getString(4);
      final String strStart=cursor.getString(5);
      final String strEnd=cursor.getString(6);
      final String location=cursor.getString(7);
      try {
        dtstart=new SimpleDateFormat("String_Node_Str",Locale.ENGLISH).parse(strStart);
        dtend=new SimpleDateFormat("String_Node_Str",Locale.ENGLISH).parse(strEnd);
        Calendar beginTime=Calendar.getInstance();
        beginTime.setTime(dtstart);
        Calendar endTime=Calendar.getInstance();
        endTime.setTime(dtend);
        long startMillis=beginTime.getTimeInMillis();
        long endMillis=endTime.getTimeInMillis();
        ContentValues values=new ContentValues();
        values.put(CalendarContract.Events.DTSTART,startMillis);
        values.put(CalendarContract.Events.DTEND,endMillis);
        values.put(CalendarContract.Events.TITLE,title);
        values.put(CalendarContract.Events.DESCRIPTION,description);
        values.put(CalendarContract.Events.CALENDAR_ID,id);
        values.put(CalendarContract.Events.EVENT_LOCATION,location);
        values.put(CalendarContract.Events.EVENT_TIMEZONE,R.string.calendarTimeZone);
        contentResolver.insert(CalendarContract.Events.CONTENT_URI,values);
      }
 catch (      ParseException e) {
        Utils.log(e);
      }
    }
  }
 }

Fixed version (ground truth):
private static void addEvents(Context c,Uri uri){
  if (ContextCompat.checkSelfPermission(c,Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
    return;
  }
  ContentResolver contentResolver=c.getContentResolver();
  String id="String_Node_Str";
  try (Cursor cursor=contentResolver.query(uri,PROJECTION,null,null,null)){
    while (cursor.moveToNext()) {
      id=cursor.getString(0);
    }
  }
   CalendarManager calendarManager=new CalendarManager(c);
  try (Cursor cursor=calendarManager.getAllFromDb()){
    while (cursor.moveToNext()) {
      final String title=cursor.getString(3);
      final String description=cursor.getString(4);
      final String strStart=cursor.getString(5);
      final String strEnd=cursor.getString(6);
      final String location=cursor.getString(7);
      long startMillis=Utils.getDateTime(strStart).getTime();
      long endMillis=Utils.getDateTime(strEnd).getTime();
      ContentValues values=new ContentValues();
      values.put(CalendarContract.Events.DTSTART,startMillis);
      values.put(CalendarContract.Events.DTEND,endMillis);
      values.put(CalendarContract.Events.TITLE,title);
      values.put(CalendarContract.Events.DESCRIPTION,description);
      values.put(CalendarContract.Events.CALENDAR_ID,id);
      values.put(CalendarContract.Events.EVENT_LOCATION,location);
      values.put(CalendarContract.Events.EVENT_TIMEZONE,R.string.calendarTimeZone);
      contentResolver.insert(CalendarContract.Events.CONTENT_URI,values);
    }
  }
 }