nus-yam/ex-repair huggingface dataset:
Program: 161485
Project: 161485
Buggy source:
@Override protected void onPostExecute(Optional<T> result){
  if (result.isPresent()) {
    Utils.logv("String_Node_Str" + result + '>');
  }
 else {
    Utils.log("String_Node_Str");
  }
  if (!NetUtils.isConnected(mContext)) {
    if (result.isPresent()) {
      Utils.showToast(mContext,R.string.no_internet_connection);
    }
 else {
      listener.onNoInternetError();
      return;
    }
  }
  if (!result.isPresent()) {
    String error;
    if (lastError.contains(TOKEN_NOT_CONFIRMED)) {
      error=context.getString(R.string.dialog_access_token_invalid);
    }
 else     if (lastError.contains(NO_FUNCTION_RIGHTS)) {
      error=context.getString(R.string.dialog_no_rights_function);
    }
 else     if (lastError.isEmpty()) {
      error=context.getString(R.string.empty_result);
    }
 else {
      error=lastError;
    }
    listener.onFetchError(error);
    return;
  }
  tumManager.releaseLock(TUMOnlineRequest.this.getRequestURL());
  listener.onFetch(result.get());
}

Fixed version (ground truth):
@Override protected void onPostExecute(Optional<T> result){
  if (result.isPresent()) {
    Utils.logv("String_Node_Str" + result + '>');
  }
 else {
    Utils.log("String_Node_Str");
  }
  if (!NetUtils.isConnected(mContext)) {
    if (result.isPresent()) {
      Utils.showToast(mContext,R.string.no_internet_connection);
    }
 else {
      listener.onNoInternetError();
      return;
    }
  }
  if (!result.isPresent()) {
    if (lastError.contains(NO_ENTRIES)) {
      listener.onNoDataToShow();
      return;
    }
    String error;
    if (lastError.contains(TOKEN_NOT_CONFIRMED)) {
      error=context.getString(R.string.dialog_access_token_invalid);
    }
 else     if (lastError.contains(NO_FUNCTION_RIGHTS)) {
      error=context.getString(R.string.dialog_no_rights_function);
    }
 else     if (lastError.isEmpty()) {
      error=context.getString(R.string.empty_result);
    }
 else {
      error=lastError;
    }
    listener.onFetchError(error);
    return;
  }
  tumManager.releaseLock(TUMOnlineRequest.this.getRequestURL());
  listener.onFetch(result.get());
}
Program: 161486
Project: 161486
Buggy source:
@Override public List<WeekViewEvent> onMonthChange(int newYear,int newMonth){
  this.newYear=newYear;
  this.newMonth=newMonth;
  if (!isLoaded(newYear,newMonth)) {
    Calendar calendar=Calendar.getInstance();
    calendar.set(newYear,newMonth - 1,1);
    int daysInMonth=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    String startTime=Long.toString(calendar.getTimeInMillis());
    calendar.set(newYear,newMonth - 1,daysInMonth);
    String endTime=Long.toString(calendar.getTimeInMillis());
    startLoading(roomApiCode,startTime,endTime);
    return new ArrayList<>();
  }
  return loadedEvents.get(calculateLoadedKey(newYear,newMonth));
}

Fixed version (ground truth):
@Override public List<WeekViewEvent> onMonthChange(int newYear,int newMonth){
  if (!isLoaded(newYear,newMonth)) {
    loadEventsInBackground(newYear,newMonth);
    return new ArrayList<>();
  }
  return loadedEvents.get(calculateLoadedKey(newYear,newMonth));
}
Program: 161487
Project: 161487
Buggy source:
private void onLoadFinished(Optional<List<RoomFinderSchedule>> result){
  if (!result.isPresent()) {
    return;
  }
  List<RoomFinderSchedule> schedules=result.get();
  List<WeekViewEvent> events=new ArrayList<>(schedules.size());
  for (  RoomFinderSchedule schedule : schedules) {
    Calendar startCal=Calendar.getInstance();
    startCal.setTime(Utils.getISODateTime(schedule.getStart()));
    Calendar endCal=Calendar.getInstance();
    endCal.setTime(Utils.getISODateTime(schedule.getEnd()));
    IntegratedCalendarEvent calendarEvent=new IntegratedCalendarEvent(schedule.getEvent_id(),schedule.getTitle(),startCal,endCal,"String_Node_Str",IntegratedCalendarEvent.getDisplayColorFromColor(0xff28921f));
    events.add(calendarEvent);
  }
  loadedEvents.put(calculateLoadedKey(newYear,newMonth),events);
  mWeekView.notifyDatasetChanged();
}

Fixed version (ground truth):
private void onLoadFinished(Optional<List<RoomFinderSchedule>> result){
  List<RoomFinderSchedule> schedules;
  if (result.isPresent()) {
    schedules=result.get();
  }
 else {
    schedules=new ArrayList<>();
  }
  List<WeekViewEvent> events=new ArrayList<>(schedules.size());
  for (  RoomFinderSchedule schedule : schedules) {
    Calendar startCal=Calendar.getInstance();
    startCal.setTime(Utils.getISODateTime(schedule.getStart()));
    Calendar endCal=Calendar.getInstance();
    endCal.setTime(Utils.getISODateTime(schedule.getEnd()));
    IntegratedCalendarEvent calendarEvent=new IntegratedCalendarEvent(schedule.getEvent_id(),schedule.getTitle(),startCal,endCal,"String_Node_Str",IntegratedCalendarEvent.getDisplayColorFromColor(0xff28921f));
    events.add(calendarEvent);
  }
  loadedEvents.put(calculateLoadedKey(newYear,newMonth),events);
  mWeekView.notifyDatasetChanged();
}
Program: 161488
Project: 161488
Buggy source:
/** 
 * Called after using getInstance() to initialize correct variables
 * @param context
 * @return
 */
public synchronized FavoriteFoodAlarmStorage initialize(Context context){
  this.context=context;
  this.sharedPreferences=context.getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE);
  this.editor=sharedPreferences.edit();
  return this;
}

Fixed version (ground truth):
/** 
 * Called after using getInstance() to initialize correct variables
 * @param context
 * @return
 */
public synchronized FavoriteFoodAlarmStorage initialize(Context context){
  this.context=context;
  this.sharedPreferences=this.context.getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE);
  this.editor=this.sharedPreferences.edit();
  return this;
}
Program: 161489
Project: 161489
Buggy source:
/** 
 * Prepares a bundle, which can be sent to the FavoriteDishAlarmScheduler, which contains all necessary information to schedule the FavoriteDishAlarms. Its procedure is the following: Get the names of all the favorite dishes and their corresponding mensaId (the user flags a food as favorite, which also stores the mensaId). By assuming that the user will only rate the food as a favorite, if he actually goes to that specific mensa. The alarm is then stored and scheduled, if it's not scheduled already.
 * @param completeReschedule True if all currently scheduled alarms should be discarded, False if not
 */
public void scheduleFoodAlarms(boolean completeReschedule){
  FavoriteFoodAlarmStorage favoriteFoodAlarmStorage=FavoriteFoodAlarmStorage.getInstance(mContext);
  if (completeReschedule) {
    favoriteFoodAlarmStorage.cancelOutstandingAlarms();
  }
  Cursor favoriteFoodWhere=db.rawQuery("String_Node_Str",null);
  while (favoriteFoodWhere.moveToNext()) {
    int mensaId=favoriteFoodWhere.getInt(0);
    String dishName=favoriteFoodWhere.getString(1);
    Cursor upcomingServings=db.rawQuery("String_Node_Str",new String[]{"String_Node_Str" + mensaId,dishName});
    while (upcomingServings.moveToNext()) {
      favoriteFoodAlarmStorage.scheduleAlarm(upcomingServings.getString(0));
    }
  }
}

Fixed version (ground truth):
/** 
 * Prepares a bundle, which can be sent to the FavoriteDishAlarmScheduler, which contains all necessary information to schedule the FavoriteDishAlarms. Its procedure is the following: Get the names of all the favorite dishes and their corresponding mensaId (the user flags a food as favorite, which also stores the mensaId). By assuming that the user will only rate the food as a favorite, if he actually goes to that specific mensa. The alarm is then stored and scheduled, if it's not scheduled already.
 * @param completeReschedule True if all currently scheduled alarms should be discarded, False if not
 */
public void scheduleFoodAlarms(boolean completeReschedule){
  FavoriteFoodAlarmStorage favoriteFoodAlarmStorage=FavoriteFoodAlarmStorage.getInstance().initialize(mContext);
  if (completeReschedule) {
    favoriteFoodAlarmStorage.cancelOutstandingAlarms();
  }
  Cursor favoriteFoodWhere=db.rawQuery("String_Node_Str",null);
  while (favoriteFoodWhere.moveToNext()) {
    int mensaId=favoriteFoodWhere.getInt(0);
    String dishName=favoriteFoodWhere.getString(1);
    Cursor upcomingServings=db.rawQuery("String_Node_Str",new String[]{"String_Node_Str" + mensaId,dishName});
    while (upcomingServings.moveToNext()) {
      favoriteFoodAlarmStorage.scheduleAlarm(upcomingServings.getString(0));
    }
  }
}
Program: 161491
Project: 161491
Buggy source:
public FavoriteDishAlarmScheduler(Calendar triggeredAt,Context context){
  Calendar scheduledAt=(Calendar)triggeredAt.clone();
  if (!loadTriggerHourAndMinute(context,scheduledAt)) {
    return;
  }
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Intent intent=new Intent(context,FavoriteDishAlarmScheduler.class);
  intent.putExtra("String_Node_Str",Utils.getDateString(triggeredAt.getTime()));
  PendingIntent schedule=PendingIntent.getBroadcast(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
  alarmManager.set(AlarmManager.RTC_WAKEUP,scheduledAt.getTimeInMillis(),schedule);
}

Fixed version (ground truth):
public FavoriteDishAlarmScheduler(Calendar triggeredAtDayMonthYear,Context context){
  Calendar scheduledAt=(Calendar)triggeredAtDayMonthYear.clone();
  if (!loadTriggerHourAndMinute(context,scheduledAt)) {
    return;
  }
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Intent intent=new Intent(context,FavoriteDishAlarmScheduler.class);
  intent.putExtra("String_Node_Str",Utils.getDateString(triggeredAtDayMonthYear.getTime()));
  PendingIntent schedule=PendingIntent.getBroadcast(context,triggeredAtDayMonthYear.hashCode(),intent,PendingIntent.FLAG_UPDATE_CURRENT);
  if (Build.VERSION.SDK_INT < 19) {
    alarmManager.set(AlarmManager.RTC_WAKEUP,scheduledAt.getTimeInMillis(),schedule);
  }
 else {
    alarmManager.setWindow(AlarmManager.RTC_WAKEUP,scheduledAt.getTimeInMillis(),2000,schedule);
  }
}
Program: 161493
Project: 161493
Buggy source:
@Override protected void onResume(){
  super.onResume();
  Intent cancelPendingFoodNotifications=new Intent(this,FavoriteDishAlarmScheduler.class);
  cancelPendingFoodNotifications.putExtra(FavoriteDishAlarmScheduler.INTENT_CANCEL_ALL_NOTIFICATIONS,true);
  sendBroadcast(cancelPendingFoodNotifications);
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
}
Program: 161498
Project: 161498
Buggy source:
public FavoriteDishAlarmScheduler(Calendar triggeredAt,Context context){
  Calendar scheduledAt=(Calendar)triggeredAt.clone();
  if (!loadTriggerHourAndMinute(context,scheduledAt)) {
    return;
  }
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Intent intent=new Intent(context,FavoriteDishAlarmScheduler.class);
  intent.putExtra("String_Node_Str",Utils.getDateString(triggeredAt.getTime()));
  PendingIntent schedule=PendingIntent.getBroadcast(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
  alarmManager.set(AlarmManager.RTC_WAKEUP,scheduledAt.getTimeInMillis(),schedule);
}

Fixed version (ground truth):
public FavoriteDishAlarmScheduler(Calendar triggeredAtDayMonthYear,Context context){
  Calendar scheduledAt=(Calendar)triggeredAtDayMonthYear.clone();
  if (!loadTriggerHourAndMinute(context,scheduledAt)) {
    return;
  }
  AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  Intent intent=new Intent(context,FavoriteDishAlarmScheduler.class);
  intent.putExtra("String_Node_Str",Utils.getDateString(triggeredAtDayMonthYear.getTime()));
  PendingIntent schedule=PendingIntent.getBroadcast(context,triggeredAtDayMonthYear.hashCode(),intent,PendingIntent.FLAG_UPDATE_CURRENT);
  if (Build.VERSION.SDK_INT < 19) {
    alarmManager.set(AlarmManager.RTC_WAKEUP,scheduledAt.getTimeInMillis(),schedule);
  }
 else {
    alarmManager.setWindow(AlarmManager.RTC_WAKEUP,scheduledAt.getTimeInMillis(),2000,schedule);
  }
}
Program: 161500
Project: 161500
Buggy source:
@Override protected void onResume(){
  super.onResume();
  Intent cancelPendingFoodNotifications=new Intent(this,FavoriteDishAlarmScheduler.class);
  cancelPendingFoodNotifications.putExtra(FavoriteDishAlarmScheduler.INTENT_CANCEL_ALL_NOTIFICATIONS,true);
  sendBroadcast(cancelPendingFoodNotifications);
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
}
Program: 161503
Project: 161503
Buggy source:
@Override public boolean onPreferenceStartScreen(PreferenceFragmentCompat preferenceFragmentCompat,PreferenceScreen preferenceScreen){
  FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
  SettingsFragment fragment=new SettingsFragment();
  Bundle args=new Bundle();
  args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT,preferenceScreen.getKey());
  fragment.setArguments(args);
  ft.add(R.id.settings_frame,fragment,preferenceScreen.getKey());
  ft.addToBackStack(preferenceScreen.getKey());
  ft.commit();
  return true;
}

Fixed version (ground truth):
@Override public boolean onPreferenceStartScreen(PreferenceFragmentCompat preferenceFragmentCompat,PreferenceScreen preferenceScreen){
  FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
  SettingsFragment fragment=new SettingsFragment();
  Bundle args=new Bundle();
  args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT,preferenceScreen.getKey());
  fragment.setArguments(args);
  ft.replace(R.id.settings_frame,fragment,preferenceScreen.getKey());
  ft.addToBackStack(preferenceScreen.getKey());
  ft.commit();
  return true;
}
Program: 161504
Project: 161504
Buggy source:
@Override public void onDataSetChanged(){
  CalendarManager calendarManager=new CalendarManager(this.applicationContext);
  calendarEvents=calendarManager.getNextDaysFromDb(14);
  Collections.sort(calendarEvents);
  Calendar currentDate=Calendar.getInstance();
  Date startDate=new Date();
  startDate.setTime(0);
  currentDate.setTime(startDate);
  for (  IntegratedCalendarEvent calendarEvent : calendarEvents) {
    Calendar calendarDate=calendarEvent.getStartTime();
    if (!DateUtils.isSameDay(currentDate,calendarDate)) {
      currentDate=calendarDate;
      calendarEvent.setIsFirstOnDay(true);
    }
  }
}

Fixed version (ground truth):
@Override public void onDataSetChanged(){
  CalendarManager calendarManager=new CalendarManager(this.applicationContext);
  calendarEvents=calendarManager.getNextDaysFromDb(14);
  Calendar currentDate=Calendar.getInstance();
  Date startDate=new Date();
  startDate.setTime(0);
  currentDate.setTime(startDate);
  for (  IntegratedCalendarEvent calendarEvent : calendarEvents) {
    Calendar calendarDate=calendarEvent.getStartTime();
    if (!DateUtils.isSameDay(currentDate,calendarDate)) {
      currentDate=calendarDate;
      calendarEvent.setIsFirstOnDay(true);
    }
  }
}
Program: 161505
Project: 161505
Buggy source:
@Override public RemoteViews getViewAt(int position){
  RemoteViews rv=new RemoteViews(applicationContext.getPackageName(),R.layout.timetable_widget_item);
  if (this.calendarEvents == null) {
    return rv;
  }
  IntegratedCalendarEvent currentItem=this.calendarEvents.get(position);
  if (currentItem == null) {
    return null;
  }
  Calendar calendar=currentItem.getStartTime();
  if (currentItem.isFirstOnDay()) {
    rv.setTextViewText(R.id.timetable_widget_date_day,String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
    rv.setTextViewText(R.id.timetable_widget_date_weekday,calendar.getDisplayName(Calendar.DAY_OF_WEEK,Calendar.SHORT,Locale.getDefault()));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      rv.setViewPadding(R.id.timetable_widget_item,0,15,0,0);
    }
  }
  rv.setInt(R.id.timetable_widget_event,"String_Node_Str",currentItem.getColor());
  rv.setTextViewText(R.id.timetable_widget_event_title,currentItem.getName());
  DateFormat timeFormat=android.text.format.DateFormat.getTimeFormat(applicationContext);
  String time=timeFormat.format(currentItem.getStartTime().getTime());
  time+="String_Node_Str" + timeFormat.format(currentItem.getEndTime().getTime());
  rv.setTextViewText(R.id.timetable_widget_event_time,time);
  rv.setTextViewText(R.id.timetable_widget_event_location,currentItem.getLocation());
  return rv;
}

Fixed version (ground truth):
@Override public RemoteViews getViewAt(int position){
  RemoteViews rv=new RemoteViews(applicationContext.getPackageName(),R.layout.timetable_widget_item);
  if (this.calendarEvents == null) {
    return rv;
  }
  IntegratedCalendarEvent currentItem=this.calendarEvents.get(position);
  if (currentItem == null) {
    return null;
  }
  Calendar calendar=currentItem.getStartTime();
  if (currentItem.isFirstOnDay()) {
    rv.setTextViewText(R.id.timetable_widget_date_day,String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
    rv.setTextViewText(R.id.timetable_widget_date_weekday,calendar.getDisplayName(Calendar.DAY_OF_WEEK,Calendar.SHORT,Locale.getDefault()));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      rv.setViewPadding(R.id.timetable_widget_item,0,15,0,0);
    }
  }
 else {
    rv.setTextViewText(R.id.timetable_widget_date_day,"String_Node_Str");
    rv.setTextViewText(R.id.timetable_widget_date_weekday,"String_Node_Str");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      rv.setViewPadding(R.id.timetable_widget_item,0,0,0,0);
    }
  }
  rv.setInt(R.id.timetable_widget_event,"String_Node_Str",currentItem.getColor());
  rv.setTextViewText(R.id.timetable_widget_event_title,currentItem.getName());
  DateFormat timeFormat=android.text.format.DateFormat.getTimeFormat(applicationContext);
  String time=timeFormat.format(currentItem.getStartTime().getTime());
  time+="String_Node_Str" + timeFormat.format(currentItem.getEndTime().getTime());
  rv.setTextViewText(R.id.timetable_widget_event_time,time);
  rv.setTextViewText(R.id.timetable_widget_event_location,currentItem.getLocation());
  return rv;
}
Program: 161506
Project: 161506
Buggy source:
private void displayDebugInfo(){
  TableLayout table=(TableLayout)findViewById(R.id.debugInfos);
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(this);
  this.addDebugRow(table,"String_Node_Str",sp.getString(Const.LRZ_ID,"String_Node_Str"));
  this.addDebugRow(table,"String_Node_Str",sp.getString(Const.ACCESS_TOKEN,"String_Node_Str"));
  this.addDebugRow(table,"String_Node_Str",sp.getBoolean(Const.BUG_REPORTS,false) + "String_Node_Str");
  this.addDebugRow(table,"String_Node_Str",Utils.getInternalSettingString(this,Const.GCM_REG_ID,"String_Node_Str"));
  this.addDebugRow(table,"String_Node_Str",DateUtils.getRelativeDateTimeString(this,Utils.getInternalSettingLong(this,Const.GCM_REG_ID_LAST_TRANSMISSION,0),DateUtils.MINUTE_IN_MILLIS,DateUtils.DAY_IN_MILLIS * 2,0).toString());
  table.setVisibility(View.VISIBLE);
}

Fixed version (ground truth):
private void displayDebugInfo(){
  TableLayout table=(TableLayout)findViewById(R.id.debugInfos);
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(this);
  this.addDebugRow(table,"String_Node_Str",sp.getString(Const.LRZ_ID,"String_Node_Str"));
  this.addDebugRow(table,"String_Node_Str",sp.getString(Const.ACCESS_TOKEN,"String_Node_Str"));
  this.addDebugRow(table,"String_Node_Str",sp.getBoolean(Const.BUG_REPORTS,false) + "String_Node_Str");
  this.addDebugRow(table,"String_Node_Str",Utils.getInternalSettingString(this,Const.GCM_REG_ID,"String_Node_Str"));
  this.addDebugRow(table,"String_Node_Str",DateUtils.getRelativeDateTimeString(this,Utils.getInternalSettingLong(this,Const.GCM_REG_ID_LAST_TRANSMISSION,0),DateUtils.MINUTE_IN_MILLIS,DateUtils.DAY_IN_MILLIS * 2,0).toString());
  try {
    PackageInfo packageInfo=getPackageManager().getPackageInfo(getPackageName(),0);
    this.addDebugRow(table,"String_Node_Str",String.valueOf(packageInfo.versionCode));
  }
 catch (  NameNotFoundException e) {
    Utils.log(e);
  }
  table.setVisibility(View.VISIBLE);
}
Program: 161507
Project: 161507
Buggy source:
private void populateNewsSources(){
  PreferenceCategory newsSources=(PreferenceCategory)findPreference("String_Node_Str");
  NewsManager cm=new NewsManager(mContext);
  Cursor cur=cm.getNewsSources();
  if (cur.moveToFirst()) {
    do {
      final CheckBoxPreference pref=new CheckBoxPreference(mContext);
      pref.setKey("String_Node_Str" + cur.getString(0));
      pref.setDefaultValue(true);
      if (Build.VERSION.SDK_INT >= 11) {
        final String url=cur.getString(1);
        new Thread(new Runnable(){
          @Override public void run(){
            NetUtils net=new NetUtils(mContext);
            try {
              final Optional<Bitmap> bmp=net.downloadImageToBitmap(url);
              if (!bmp.isPresent()) {
                return;
              }
              mContext.runOnUiThread(new Runnable(){
                @TargetApi(11) @Override public void run(){
                  pref.setIcon(new BitmapDrawable(getResources(),bmp.get()));
                }
              }
);
            }
 catch (            NullPointerException e) {
            }
          }
        }
).start();
      }
      pref.setTitle(cur.getString(2));
      newsSources.addPreference(pref);
    }
 while (cur.moveToNext());
  }
  cur.close();
}

Fixed version (ground truth):
private void populateNewsSources(){
  PreferenceCategory newsSources=(PreferenceCategory)findPreference("String_Node_Str");
  NewsManager cm=new NewsManager(mContext);
  Cursor cur=cm.getNewsSources();
  if (cur.moveToFirst()) {
    do {
      final CheckBoxPreference pref=new CheckBoxPreference(mContext);
      pref.setKey("String_Node_Str" + cur.getString(0));
      pref.setDefaultValue(true);
      if (Build.VERSION.SDK_INT >= 11) {
        final String url=cur.getString(1);
        new Thread(new Runnable(){
          @Override public void run(){
            NetUtils net=new NetUtils(mContext);
            final Optional<Bitmap> bmp=net.downloadImageToBitmap(url);
            mContext.runOnUiThread(new Runnable(){
              @TargetApi(11) @Override public void run(){
                if (bmp.isPresent()) {
                  pref.setIcon(new BitmapDrawable(getResources(),bmp.get()));
                }
              }
            }
);
          }
        }
).start();
      }
      pref.setTitle(cur.getString(2));
      newsSources.addPreference(pref);
    }
 while (cur.moveToNext());
  }
  cur.close();
}
Program: 161508
Project: 161508
Buggy source:
@TargetApi(11) @Override public void run(){
  pref.setIcon(new BitmapDrawable(getResources(),bmp.get()));
}

Fixed version (ground truth):
@TargetApi(11) @Override public void run(){
  if (bmp.isPresent()) {
    pref.setIcon(new BitmapDrawable(getResources(),bmp.get()));
  }
}
Program: 161509
Project: 161509
Buggy source:
public static void loadGeo(Context c){
  LocationManager locationManager=new LocationManager(c);
  SQLiteDatabase db=getDb(c);
  Cursor cur=db.rawQuery("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",null);
  if (cur.moveToFirst()) {
    do {
      String location=cur.getString(0);
      if (location != null && !location.isEmpty()) {
        Optional<Geo> geo=locationManager.roomLocationStringToGeo(location);
        if (geo.isPresent()) {
          Utils.logv("String_Node_Str" + location + ' '+ geo);
          db.execSQL("String_Node_Str",new String[]{location,geo.get().getLatitude(),geo.get().getLongitude()});
        }
      }
    }
 while (cur.moveToNext());
  }
  cur.close();
  boolean syncCalendar=Utils.getInternalSettingBool(c,Const.SYNC_CALENDAR,false) && ContextCompat.checkSelfPermission(c,Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED;
  if (syncCalendar && new SyncManager(c).needSync(Const.SYNC_CALENDAR,TIME_TO_SYNC_CALENDAR)) {
    syncCalendar(c);
    new SyncManager(c).replaceIntoDb(Const.SYNC_CALENDAR);
  }
}

Fixed version (ground truth):
public static void loadGeo(Context c){
  LocationManager locationManager=new LocationManager(c);
  SQLiteDatabase db=getDb(c);
  Cursor cur=db.rawQuery("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",null);
  if (cur.moveToFirst()) {
    do {
      String location=cur.getString(0);
      if (location == null || location.isEmpty()) {
        continue;
      }
      Optional<Geo> geo=locationManager.roomLocationStringToGeo(location);
      if (geo.isPresent()) {
        Utils.logv("String_Node_Str" + location + ' '+ geo);
        db.execSQL("String_Node_Str",new String[]{location,geo.get().getLatitude(),geo.get().getLongitude()});
      }
    }
 while (cur.moveToNext());
  }
  cur.close();
  boolean syncCalendar=Utils.getInternalSettingBool(c,Const.SYNC_CALENDAR,false) && ContextCompat.checkSelfPermission(c,Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED;
  if (syncCalendar && new SyncManager(c).needSync(Const.SYNC_CALENDAR,TIME_TO_SYNC_CALENDAR)) {
    syncCalendar(c);
    new SyncManager(c).replaceIntoDb(Const.SYNC_CALENDAR);
  }
}
Program: 161510
Project: 161510
Buggy source:
/** 
 * Adds the newest news card
 * @param context Context
 */
@Override public void onRequestCard(Context context){
  StringBuilder and=new StringBuilder();
  Cursor c=getNewsSources();
  if (c.moveToFirst()) {
    do {
      int id=c.getInt(0);
      boolean show=Utils.getSettingBool(context,"String_Node_Str" + id,true);
      if (show) {
        if (!and.toString().isEmpty()) {
          and.append("String_Node_Str");
        }
        and.append("String_Node_Str").append(id).append('\"');
      }
    }
 while (c.moveToNext());
  }
  c.close();
  if (!and.toString().isEmpty()) {
    StringBuilder query=new StringBuilder("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    if (Utils.getSettingBool(context,"String_Node_Str",true)) {
      query.append("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    }
 else {
      query.append("String_Node_Str");
    }
    query.append("String_Node_Str").append(and).append("String_Node_Str").append("String_Node_Str");
    Cursor cur=db.rawQuery(query.toString(),null);
    int i=0;
    if (cur.moveToFirst()) {
      do {
        NewsCard card;
        if (FilmCard.isNewsAFilm(cur,i)) {
          card=new FilmCard(context);
        }
 else {
          card=new NewsCard(context);
        }
        card.setNews(cur,i);
        card.apply();
        i++;
      }
 while (cur.moveToNext());
    }
 else {
      cur.close();
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds the newest news card
 * @param context Context
 */
@Override public void onRequestCard(Context context){
  StringBuilder and=new StringBuilder();
  Cursor c=getNewsSources();
  if (c.moveToFirst()) {
    do {
      int id=c.getInt(0);
      boolean show=Utils.getSettingBool(context,"String_Node_Str" + id,true);
      if (!show) {
        continue;
      }
      if (!and.toString().isEmpty()) {
        and.append("String_Node_Str");
      }
      and.append("String_Node_Str").append(id).append('\"');
    }
 while (c.moveToNext());
  }
  c.close();
  if (!and.toString().isEmpty()) {
    StringBuilder query=new StringBuilder("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    if (Utils.getSettingBool(context,"String_Node_Str",true)) {
      query.append("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    }
 else {
      query.append("String_Node_Str");
    }
    query.append("String_Node_Str").append(and).append("String_Node_Str").append("String_Node_Str");
    Cursor cur=db.rawQuery(query.toString(),null);
    int i=0;
    if (cur.moveToFirst()) {
      do {
        NewsCard card;
        if (FilmCard.isNewsAFilm(cur,i)) {
          card=new FilmCard(context);
        }
 else {
          card=new NewsCard(context);
        }
        card.setNews(cur,i);
        card.apply();
        i++;
      }
 while (cur.moveToNext());
    }
 else {
      cur.close();
    }
  }
}
Program: 161511
Project: 161511
Buggy source:
/** 
 * Get all news from the database
 * @return Database cursor (_id, src, title, description, link, image, date, created, icon, source)
 */
public Cursor getAllFromDb(Context context){
  String selectedNewspread=Utils.getSetting(mContext,"String_Node_Str","String_Node_Str");
  StringBuilder and=new StringBuilder();
  Cursor c=getNewsSources();
  if (c.moveToFirst()) {
    do {
      int id=c.getInt(0);
      boolean show=Utils.getSettingBool(context,"String_Node_Str" + id,id <= 7);
      if (show) {
        if (!and.toString().isEmpty()) {
          and.append("String_Node_Str");
        }
        and.append("String_Node_Str").append(id).append('\"');
      }
    }
 while (c.moveToNext());
  }
  c.close();
  return db.rawQuery("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + (and.toString().isEmpty() ? "String_Node_Str" : "String_Node_Str" + and.toString() + "String_Node_Str") + "String_Node_Str"+ "String_Node_Str",new String[]{selectedNewspread});
}

Fixed version (ground truth):
/** 
 * Get all news from the database
 * @return Database cursor (_id, src, title, description, link, image, date, created, icon, source)
 */
public Cursor getAllFromDb(Context context){
  String selectedNewspread=Utils.getSetting(mContext,"String_Node_Str","String_Node_Str");
  StringBuilder and=new StringBuilder();
  Cursor c=getNewsSources();
  if (c.moveToFirst()) {
    do {
      int id=c.getInt(0);
      boolean show=Utils.getSettingBool(context,"String_Node_Str" + id,id <= 7);
      if (!show) {
        continue;
      }
      if (!and.toString().isEmpty()) {
        and.append("String_Node_Str");
      }
      and.append("String_Node_Str").append(id).append('\"');
    }
 while (c.moveToNext());
  }
  c.close();
  return db.rawQuery("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + (and.toString().isEmpty() ? "String_Node_Str" : "String_Node_Str" + and.toString() + "String_Node_Str") + "String_Node_Str"+ "String_Node_Str",new String[]{selectedNewspread});
}
Program: 161512
Project: 161512
Buggy source:
/** 
 * Calculates the average grade of the given exams
 * @param filteredExamList List of exams
 * @return Average grade
 */
Double calculateAverageGrade(List<Exam> filteredExamList){
  List<Exam> removedDoubles=removeDuplicates(filteredExamList);
  double weightedGrade=0.0;
  double creditSum=0.0;
  for (  Exam item : removedDoubles) {
    creditSum+=Double.valueOf(item.getCredits());
    try {
      weightedGrade+=format.parse(item.getGrade()).doubleValue() * Double.valueOf(item.getCredits());
    }
 catch (    NumberFormatException|ParseException e) {
      Utils.log(e);
    }
  }
  return weightedGrade / creditSum;
}

Fixed version (ground truth):
/** 
 * Calculates the average grade of the given exams
 * @param filteredExamList List of exams
 * @return Average grade
 */
Double calculateAverageGrade(List<Exam> filteredExamList){
  double weightedGrade=0.0;
  double creditSum=0.0;
  for (  Exam item : filteredExamList) {
    creditSum+=Double.valueOf(item.getCredits());
    try {
      weightedGrade+=format.parse(item.getGrade()).doubleValue() * Double.valueOf(item.getCredits());
    }
 catch (    NumberFormatException|ParseException e) {
      Utils.log(e);
    }
  }
  return weightedGrade / creditSum;
}
Program: 161513
Project: 161513
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  overridePendingTransition(R.anim.fadein,R.anim.fadeout);
  preferences=PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  Intent i=getIntent();
  if (i != null && i.hasExtra(Const.TOKEN_IS_SETUP)) {
    tokenSetup=i.getBooleanExtra(Const.TOKEN_IS_SETUP,false);
  }
  checkSilentMode=(CheckBox)findViewById(R.id.chk_silent_mode);
  bugReport=(CheckBox)findViewById(R.id.chk_bug_reports);
  if (new AccessTokenManager(this).hasValidAccessToken()) {
    checkSilentMode.setChecked(preferences.getBoolean(Const.SILENCE_SERVICE,true));
  }
 else {
    checkSilentMode.setChecked(false);
    checkSilentMode.setEnabled(false);
  }
  groupChatMode=(CheckBox)findViewById(R.id.chk_group_chat);
  if (new AccessTokenManager(this).hasValidAccessToken()) {
    groupChatMode.setChecked(preferences.getBoolean(Const.GROUP_CHAT_ENABLED,true));
  }
 else {
    groupChatMode.setChecked(false);
    groupChatMode.setEnabled(false);
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  overridePendingTransition(R.anim.fadein,R.anim.fadeout);
  preferences=PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  Intent i=getIntent();
  if (i != null && i.hasExtra(Const.TOKEN_IS_SETUP)) {
    tokenSetup=i.getBooleanExtra(Const.TOKEN_IS_SETUP,false);
  }
  checkSilentMode=(CheckBox)findViewById(R.id.chk_silent_mode);
  bugReport=(CheckBox)findViewById(R.id.chk_bug_reports);
  bugReport.setChecked(preferences.getBoolean(Const.BUG_REPORTS,true));
  if (new AccessTokenManager(this).hasValidAccessToken()) {
    checkSilentMode.setChecked(preferences.getBoolean(Const.SILENCE_SERVICE,true));
  }
 else {
    checkSilentMode.setChecked(false);
    checkSilentMode.setEnabled(false);
  }
  groupChatMode=(CheckBox)findViewById(R.id.chk_group_chat);
  if (new AccessTokenManager(this).hasValidAccessToken()) {
    groupChatMode.setChecked(preferences.getBoolean(Const.GROUP_CHAT_ENABLED,true));
  }
 else {
    groupChatMode.setChecked(false);
    groupChatMode.setEnabled(false);
  }
}
Program: 161514
Project: 161514
Buggy source:
@Override protected ChatMember onLoadInBackground(Void... arg){
  if (groupChatMode.isChecked()) {
    if (!NetUtils.isConnected(this)) {
      showNoInternetLayout();
      return null;
    }
    ChatMember currentChatMember=new ChatMember(Utils.getSetting(this,Const.LRZ_ID,"String_Node_Str"));
    currentChatMember.setDisplayName(Utils.getSetting(this,Const.CHAT_ROOM_DISPLAY_NAME,"String_Node_Str"));
    ChatMember member;
    try {
      member=TUMCabeClient.getInstance(this).createMember(currentChatMember);
    }
 catch (    IOException e) {
      Utils.log(e);
      Utils.showToastOnUIThread(this,R.string.error_setup_chat_member);
      return null;
    }
    if (member == null || member.getLrzId() == null) {
      Utils.showToastOnUIThread(this,R.string.error_setup_chat_member);
      return null;
    }
    AuthenticationManager am=new AuthenticationManager(this);
    if (!am.generatePrivateKey(member)) {
      Utils.showToastOnUIThread(this,getString(R.string.failure_uploading_public_key));
      return null;
    }
    try {
      List<ChatRoom> rooms=TUMCabeClient.getInstance(this).getMemberRooms(member.getId(),new ChatVerification(this,member));
      new ChatRoomManager(this).replaceIntoRooms(rooms);
      Utils.setInternalSetting(this,Const.PRIVATE_KEY_ACTIVE,true);
      return member;
    }
 catch (    IOException e) {
      Utils.log(e);
    }
catch (    NoPrivateKey e) {
      Utils.log(e);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override protected ChatMember onLoadInBackground(Void... arg){
  if (!NetUtils.isConnected(this)) {
    showNoInternetLayout();
    return null;
  }
  ChatMember currentChatMember=new ChatMember(Utils.getSetting(this,Const.LRZ_ID,"String_Node_Str"));
  currentChatMember.setDisplayName(Utils.getSetting(this,Const.CHAT_ROOM_DISPLAY_NAME,"String_Node_Str"));
  if (currentChatMember.getLrzId().equals("String_Node_Str")) {
    return currentChatMember;
  }
  ChatMember member;
  try {
    member=TUMCabeClient.getInstance(this).createMember(currentChatMember);
  }
 catch (  IOException e) {
    Utils.log(e);
    Utils.showToastOnUIThread(this,R.string.error_setup_chat_member);
    return null;
  }
  if (member == null || member.getLrzId() == null) {
    Utils.showToastOnUIThread(this,R.string.error_setup_chat_member);
    return null;
  }
  AuthenticationManager am=new AuthenticationManager(this);
  if (!am.generatePrivateKey(member)) {
    Utils.showToastOnUIThread(this,getString(R.string.failure_uploading_public_key));
    return null;
  }
  try {
    List<ChatRoom> rooms=TUMCabeClient.getInstance(this).getMemberRooms(member.getId(),new ChatVerification(this,member));
    new ChatRoomManager(this).replaceIntoRooms(rooms);
    Utils.setInternalSetting(this,Const.PRIVATE_KEY_ACTIVE,true);
    return member;
  }
 catch (  IOException e) {
    Utils.log(e);
  }
catch (  NoPrivateKey e) {
    Utils.log(e);
  }
  return null;
}
Program: 161515
Project: 161515
Buggy source:
@Override protected void onLoadFinished(ChatMember member){
  if (member != null) {
    Editor editor=preferences.edit();
    editor.putBoolean(Const.SILENCE_SERVICE,checkSilentMode.isChecked());
    editor.putBoolean(Const.BACKGROUND_MODE,true);
    editor.putBoolean(Const.BUG_REPORTS,bugReport.isChecked());
    editor.putBoolean(Const.HIDE_WIZARD_ON_STARTUP,true);
    Utils.setSetting(this,Const.GROUP_CHAT_ENABLED,groupChatMode.isChecked());
    Utils.setSetting(this,Const.AUTO_JOIN_NEW_ROOMS,groupChatMode.isChecked());
    Utils.setSetting(this,Const.CHAT_MEMBER,member);
    editor.apply();
    finish();
    startActivity(new Intent(this,StartupActivity.class));
  }
 else {
    showLoadingEnded();
  }
}

Fixed version (ground truth):
@Override protected void onLoadFinished(ChatMember member){
  if (member == null) {
    showLoadingEnded();
    return;
  }
  Editor editor=preferences.edit();
  editor.putBoolean(Const.SILENCE_SERVICE,checkSilentMode.isChecked());
  editor.putBoolean(Const.BACKGROUND_MODE,true);
  editor.putBoolean(Const.BUG_REPORTS,bugReport.isChecked());
  editor.putBoolean(Const.HIDE_WIZARD_ON_STARTUP,true);
  if (!member.getLrzId().equals("String_Node_Str")) {
    Utils.setSetting(this,Const.GROUP_CHAT_ENABLED,groupChatMode.isChecked());
    Utils.setSetting(this,Const.AUTO_JOIN_NEW_ROOMS,groupChatMode.isChecked());
    Utils.setSetting(this,Const.CHAT_MEMBER,member);
  }
  editor.apply();
  finish();
  startActivity(new Intent(this,StartupActivity.class));
}
Program: 161516
Project: 161516
Buggy source:
@Override public Response intercept(Chain chain) throws IOException {
  Request newRequest=chain.request().newBuilder().addHeader("String_Node_Str",AuthenticationManager.getDeviceID(c)).build();
  return chain.proceed(newRequest);
}

Fixed version (ground truth):
@Override public Response intercept(Chain chain) throws IOException {
  Utils.log("String_Node_Str" + chain.request().url().toString());
  Request.Builder newRequest=chain.request().newBuilder().addHeader("String_Node_Str",AuthenticationManager.getDeviceID(c)).addHeader("String_Node_Str",userAgent.toString()).addHeader("String_Node_Str",Build.VERSION.RELEASE);
  try {
    newRequest.addHeader("String_Node_Str",c.getPackageManager().getPackageInfo(c.getPackageName(),0).versionName);
  }
 catch (  PackageManager.NameNotFoundException e) {
  }
  return chain.proceed(newRequest.build());
}
Program: 161517
Project: 161517
Buggy source:
private static Interceptor getDeviceInterceptor(final Context c){
  return new Interceptor(){
    @Override public Response intercept(    Chain chain) throws IOException {
      Request newRequest=chain.request().newBuilder().addHeader("String_Node_Str",AuthenticationManager.getDeviceID(c)).build();
      return chain.proceed(newRequest);
    }
  }
;
}

Fixed version (ground truth):
private static Interceptor getDeviceInterceptor(final Context c){
  final StringBuilder userAgent=new StringBuilder("String_Node_Str");
  if (G.appVersion != null && !G.appVersion.equals(G.UNKNOWN)) {
    userAgent.append(' ').append(G.appVersion);
    if (G.appVersionCode != -1) {
      userAgent.append('/').append(G.appVersionCode);
    }
  }
  return new Interceptor(){
    @Override public Response intercept(    Chain chain) throws IOException {
      Utils.log("String_Node_Str" + chain.request().url().toString());
      Request.Builder newRequest=chain.request().newBuilder().addHeader("String_Node_Str",AuthenticationManager.getDeviceID(c)).addHeader("String_Node_Str",userAgent.toString()).addHeader("String_Node_Str",Build.VERSION.RELEASE);
      try {
        newRequest.addHeader("String_Node_Str",c.getPackageManager().getPackageInfo(c.getPackageName(),0).versionName);
      }
 catch (      PackageManager.NameNotFoundException e) {
      }
      return chain.proceed(newRequest.build());
    }
  }
;
}
Program: 161518
Project: 161518
Buggy source:
@PUT(API_STATISTICS) Call<String> putStatistics(@Body Statistics r);

Fixed version (ground truth):
@PUT(API_STATISTICS) Call<List<String>> putStatistics(@Body Statistics r);
Program: 161519
Project: 161519
Buggy source:
@Override public void onFailure(Call<String> call,Throwable t){
  Utils.log(t);
}

Fixed version (ground truth):
@Override public void onFailure(Call<List<String>> call,Throwable t){
}
Program: 161520
Project: 161520
Buggy source:
@Override public void onResponse(Call<String> call,Response<String> response){
}

Fixed version (ground truth):
@Override public void onResponse(Call<List<String>> call,Response<List<String>> response){
}
Program: 161521
Project: 161521
Buggy source:
/** 
 * Gets private key from preferences or generates one.
 * @return true if a private key is present
 */
public boolean generatePrivateKey(ChatMember member){
  try {
    this.getPrivateKeyString();
    this.uploadKey(this.getPublicKeyString(),member);
    return true;
  }
 catch (  NoPrivateKey|NoPublicKey e) {
    Utils.log(e);
  }
  this.clearKeys();
  KeyPair keyPair=this.generateKeyPair();
  String publicKeyString=this.keyToBase64(keyPair.getPublic().getEncoded());
  String privateKeyString=this.keyToBase64(keyPair.getPrivate().getEncoded());
  this.saveKeys(privateKeyString,publicKeyString);
  this.uploadKey(publicKeyString,member);
  return true;
}

Fixed version (ground truth):
/** 
 * Gets private key from preferences or generates one.
 * @return true if a private key is present
 */
public boolean generatePrivateKey(ChatMember member){
  try {
    this.getPrivateKeyString();
    this.uploadKey(this.getPublicKeyString(),member);
    return true;
  }
 catch (  NoPrivateKey|NoPublicKey e) {
  }
  this.clearKeys();
  KeyPair keyPair=this.generateKeyPair();
  String publicKeyString=this.keyToBase64(keyPair.getPublic().getEncoded());
  String privateKeyString=this.keyToBase64(keyPair.getPrivate().getEncoded());
  this.saveKeys(privateKeyString,publicKeyString);
  this.uploadKey(publicKeyString,member);
  return true;
}
Program: 161525
Project: 161525
Buggy source:
/** 
 * Download cafeteria menus from external interface (JSON)
 * @param force True to force download over normal sync period, else false
 * @throws Exception
 */
public void downloadFromExternal(Context context,boolean force) throws Exception {
  if (!force && !SyncManager.needSync(db,this,TIME_TO_SYNC)) {
    return;
  }
  String url="String_Node_Str";
  JSONObject json=NetUtils.downloadJson(context,url);
  db.beginTransaction();
  removeCache();
  try {
    JSONArray menu=json.getJSONArray("String_Node_Str");
    for (int j=0; j < menu.length(); j++) {
      replaceIntoDb(getFromJson(menu.getJSONObject(j)));
    }
    JSONArray beilagen=json.getJSONArray("String_Node_Str");
    for (int j=0; j < beilagen.length(); j++) {
      replaceIntoDb(getFromJsonAddendum(beilagen.getJSONObject(j)));
    }
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
  }
  SyncManager.replaceIntoDb(db,this);
}

Fixed version (ground truth):
/** 
 * Download cafeteria menus from external interface (JSON)
 * @param force True to force download over normal sync period, else false
 * @throws Exception
 */
public void downloadFromExternal(Context context,boolean force) throws JSONException {
  if (!force && !SyncManager.needSync(db,this,TIME_TO_SYNC)) {
    return;
  }
  String url="String_Node_Str";
  Optional<JSONObject> json=NetUtils.downloadJson(context,url);
  if (!json.isPresent()) {
    return;
  }
  JSONObject obj=json.get();
  db.beginTransaction();
  removeCache();
  try {
    JSONArray menu=obj.getJSONArray("String_Node_Str");
    for (int j=0; j < menu.length(); j++) {
      replaceIntoDb(getFromJson(menu.getJSONObject(j)));
    }
    JSONArray beilagen=obj.getJSONArray("String_Node_Str");
    for (int j=0; j < beilagen.length(); j++) {
      replaceIntoDb(getFromJsonAddendum(beilagen.getJSONObject(j)));
    }
    db.setTransactionSuccessful();
  }
 catch (  Exception e) {
  }
 finally {
    db.endTransaction();
  }
  SyncManager.replaceIntoDb(db,this);
}
Program: 161526
Project: 161526
Buggy source:
/** 
 * Load departure times
 * @param arg Station name
 * @return List of departures
 */
@Override protected List<TransportManager.Departure> onLoadInBackground(String... arg){
  final String location=arg[0];
  recentsManager.replaceIntoDb(location);
  if (!NetUtils.isConnected(this)) {
    showNoInternetLayout();
    return null;
  }
  final String locationID=arg[1];
  List<TransportManager.Departure> departureCursor=TransportManager.getDeparturesFromExternal(this,locationID);
  if (departureCursor == null) {
    showError(R.string.no_departures_found);
  }
  return departureCursor;
}

Fixed version (ground truth):
/** 
 * Load departure times
 * @param arg Station name
 * @return List of departures
 */
@Override protected List<TransportManager.Departure> onLoadInBackground(String... arg){
  final String location=arg[0];
  recentsManager.replaceIntoDb(location);
  if (!NetUtils.isConnected(this)) {
    showNoInternetLayout();
    return null;
  }
  final String locationID=arg[1];
  List<TransportManager.Departure> departureCursor=TransportManager.getDeparturesFromExternal(this,locationID);
  if (departureCursor.isEmpty()) {
    showError(R.string.no_departures_found);
  }
  return departureCursor;
}
Program: 161527
Project: 161527
Buggy source:
/** 
 * Download a JSON stream from a URL
 * @param url Valid URL
 * @return JSONObject
 * @throws IOException , JSONException
 */
public Optional<JSONObject> downloadJson(String url) throws IOException, JSONException {
  Optional<String> data=downloadStringHttp(url);
  if (data.isPresent()) {
    Utils.logv("String_Node_Str" + data);
    return Optional.of(new JSONObject(data.get()));
  }
  return Optional.absent();
}

Fixed version (ground truth):
/** 
 * Download a JSON stream from a URL
 * @param url Valid URL
 * @return JSONObject
 */
public Optional<JSONObject> downloadJson(String url){
  try {
    Optional<String> data=downloadStringHttp(url);
    if (data.isPresent()) {
      Utils.logv("String_Node_Str" + data);
      return Optional.of(new JSONObject(data.get()));
    }
  }
 catch (  IOException|JSONException e) {
    Utils.log(e);
  }
  return Optional.absent();
}