Program: 25702
Project: 25702
Buggy source:
private List<ScheduledActivity> resolveLinks(CriteriaContext context,Map<String,CompoundActivity> compoundActivityCache,Map<String,SchemaReference> schemaCache,Map<String,SurveyReference> surveyCache,List<ScheduledActivity> activities){
  return activities.stream().map(schActivity -> {
    Activity activity=schActivity.getActivity();
    ActivityType activityType=activity.getActivityType();
    Activity resolvedActivity=null;
    if (activityType == ActivityType.COMPOUND) {
      CompoundActivity compoundActivity=activity.getCompoundActivity();
      CompoundActivity resolvedCompoundActivity=resolveCompoundActivity(context,compoundActivityCache,schemaCache,surveyCache,compoundActivity);
      if (!resolvedCompoundActivity.equals(compoundActivity)) {
        resolvedActivity=new Activity.Builder().withActivity(activity).withCompoundActivity(resolvedCompoundActivity).build();
      }
    }
 else     if (activityType == ActivityType.SURVEY) {
      SurveyReference surveyRef=activity.getSurvey();
      SurveyReference resolvedSurveyRef=resolveSurvey(context,surveyCache,surveyRef);
      if (!resolvedSurveyRef.equals(surveyRef)) {
        resolvedActivity=new Activity.Builder().withActivity(activity).withSurvey(resolvedSurveyRef).build();
      }
    }
 else     if (activityType == ActivityType.TASK) {
      TaskReference taskRef=activity.getTask();
      SchemaReference schemaRef=taskRef.getSchema();
      if (schemaRef != null) {
        SchemaReference resolvedSchemaRef=resolveSchema(context,schemaCache,schemaRef);
        if (!resolvedSchemaRef.equals(schemaRef)) {
          TaskReference resolvedTaskRef=new TaskReference(taskRef.getIdentifier(),resolvedSchemaRef);
          resolvedActivity=new Activity.Builder().withTask(resolvedTaskRef).build();
        }
      }
    }
    if (resolvedActivity != null) {
      schActivity.setActivity(resolvedActivity);
    }
    return schActivity;
  }
).collect(toList());
}

Fixed version (ground truth):
private List<ScheduledActivity> resolveLinks(CriteriaContext context,Map<String,CompoundActivity> compoundActivityCache,Map<String,SchemaReference> schemaCache,Map<String,SurveyReference> surveyCache,List<ScheduledActivity> activities){
  return activities.stream().map(schActivity -> {
    Activity activity=schActivity.getActivity();
    ActivityType activityType=activity.getActivityType();
    Activity resolvedActivity=null;
    if (activityType == ActivityType.COMPOUND) {
      CompoundActivity compoundActivity=activity.getCompoundActivity();
      CompoundActivity resolvedCompoundActivity=resolveCompoundActivity(context,compoundActivityCache,schemaCache,surveyCache,compoundActivity);
      if (!resolvedCompoundActivity.equals(compoundActivity)) {
        resolvedActivity=new Activity.Builder().withActivity(activity).withCompoundActivity(resolvedCompoundActivity).build();
      }
    }
 else     if (activityType == ActivityType.SURVEY) {
      SurveyReference surveyRef=activity.getSurvey();
      SurveyReference resolvedSurveyRef=resolveSurvey(context,surveyCache,surveyRef);
      if (!resolvedSurveyRef.equals(surveyRef)) {
        resolvedActivity=new Activity.Builder().withActivity(activity).withSurvey(resolvedSurveyRef).build();
      }
    }
 else     if (activityType == ActivityType.TASK) {
      TaskReference taskRef=activity.getTask();
      SchemaReference schemaRef=taskRef.getSchema();
      if (schemaRef != null) {
        SchemaReference resolvedSchemaRef=resolveSchema(context,schemaCache,schemaRef);
        if (!resolvedSchemaRef.equals(schemaRef)) {
          TaskReference resolvedTaskRef=new TaskReference(taskRef.getIdentifier(),resolvedSchemaRef);
          resolvedActivity=new Activity.Builder().withActivity(activity).withTask(resolvedTaskRef).build();
        }
      }
    }
    if (resolvedActivity != null) {
      schActivity.setActivity(resolvedActivity);
    }
    return schActivity;
  }
).collect(toList());
}