Program: 87127
Project: 87127
Buggy source:
public void start(final String profile,final Structure structure,String file,String charset,final Importer importer,final Handler<Message<JsonObject>> handler){
  importer.createOrUpdateProfile(STUDENT_PROFILE);
  importer.createOrUpdateProfile(RELATIVE_PROFILE);
  importer.createOrUpdateProfile(PERSONNEL_PROFILE);
  importer.createOrUpdateProfile(TEACHER_PROFILE);
  importer.createOrUpdateProfile(GUEST_PROFILE);
  DefaultFunctions.createOrUpdateFunctions(importer);
  final Validator validator=ManualFeeder.profiles.get(profile);
  try {
    CSVReader csvParser=getCsvReader(file,charset);
    final List<String> columns=new ArrayList<>();
    String[] strings;
    int i=0;
    while ((strings=csvParser.readNext()) != null) {
      if (i == 0) {
        columnsMapper.getColumsNames(strings,columns,handler);
      }
 else       if (!columns.isEmpty()) {
        JsonObject user=new JsonObject();
        user.putArray("String_Node_Str",new JsonArray().add(structure.getExternalId()));
        user.putArray("String_Node_Str",new JsonArray().add(profile));
        List<String[]> classes=new ArrayList<>();
        for (int j=0; j < strings.length; j++) {
          final String c=columns.get(j);
          final String v=strings[j].trim();
          if ((v.isEmpty() && !"String_Node_Str".equals(c)) || (v.isEmpty() && "String_Node_Str".equals(c) && strings[j + 1].trim().isEmpty()))           continue;
switch (validator.getType(c)) {
case "String_Node_Str":
            if ("String_Node_Str".equals(c)) {
              Matcher m=frenchDatePatter.matcher(v);
              if (m.find()) {
                user.putString(c,m.group(3) + "String_Node_Str" + m.group(2)+ "String_Node_Str"+ m.group(1));
              }
 else {
                user.putString(c,v);
              }
            }
 else {
              user.putString(c,v);
            }
          break;
case "String_Node_Str":
        JsonArray a=user.getArray(c);
      if (a == null) {
        a=new JsonArray();
        user.putArray(c,a);
      }
    if (("String_Node_Str".equals(c) || "String_Node_Str".equals(c) || "String_Node_Str".equals(c)) && !v.startsWith(structure.getExternalId() + "String_Node_Str")) {
      a.add(structure.getExternalId() + "String_Node_Str" + v);
    }
 else {
      a.add(v);
    }
  break;
case "String_Node_Str":
user.putBoolean(c,"String_Node_Str".equals(v.toLowerCase()));
break;
default :
Object o=user.getValue(c);
final String v2;
if ("String_Node_Str".equals(c) && !v.startsWith(structure.getExternalId() + "String_Node_Str")) {
v2=structure.getExternalId() + "String_Node_Str" + v;
}
 else {
v2=v;
}
if (o != null) {
if (o instanceof JsonArray) {
((JsonArray)o).add(v2);
}
 else {
JsonArray array=new JsonArray();
array.add(o).add(v2);
user.putArray(c,array);
}
}
 else {
user.putString(c,v2);
}
}
if ("String_Node_Str".equals(c)) {
String[] cc=v.split("String_Node_Str");
if (cc.length == 2 && !cc[1].matches("String_Node_Str")) {
final String fosEId=importer.getFieldOfStudy().get(cc[1]);
if (fosEId != null) {
cc[1]=fosEId;
}
}
String eId=structure.getExternalId() + '$' + cc[0];
structure.createClassIfAbsent(eId,cc[0]);
final String[] classId=new String[3];
classId[0]=structure.getExternalId();
classId[1]=eId;
classId[2]=(cc.length == 2) ? cc[1] : "String_Node_Str";
classes.add(classId);
}
}
String ca;
long seed;
JsonArray classesA;
Object co=user.getValue("String_Node_Str");
if (co != null && co instanceof JsonArray) {
classesA=(JsonArray)co;
}
 else if (co instanceof String) {
classesA=new JsonArray().add(co);
}
 else {
classesA=null;
}
if ("String_Node_Str".equals(profile) && classesA != null && classesA.size() == 1) {
seed=DEFAULT_STUDENT_SEED;
ca=classesA.get(0);
}
 else {
ca=String.valueOf(i);
seed=System.currentTimeMillis();
}
generateUserExternalId(user,ca,structure,seed);
switch (profile) {
case "String_Node_Str":
importer.createOrUpdatePersonnel(user,TEACHER_PROFILE_EXTERNAL_ID,user.getArray("String_Node_Str"),classes.toArray(new String[classes.size()][2]),null,true,true);
break;
case "String_Node_Str":
importer.createOrUpdatePersonnel(user,PERSONNEL_PROFILE_EXTERNAL_ID,user.getArray("String_Node_Str"),classes.toArray(new String[classes.size()][2]),null,true,true);
break;
case "String_Node_Str":
importer.createOrUpdateStudent(user,STUDENT_PROFILE_EXTERNAL_ID,null,null,classes.toArray(new String[classes.size()][2]),null,null,true,true);
break;
case "String_Node_Str":
JsonArray linkStudents=new JsonArray();
for (String attr : user.getFieldNames()) {
if ("String_Node_Str".equals(attr)) {
Object o=user.getValue(attr);
if (o instanceof JsonArray) {
for (Object c : (JsonArray)o) {
linkStudents.add(c);
}
}
 else {
linkStudents.add(o);
}
}
 else if ("String_Node_Str".equals(attr)) {
Object childUsername=user.getValue(attr);
Object childLastName=user.getValue("String_Node_Str");
Object childFirstName=user.getValue("String_Node_Str");
Object childClasses=user.getValue("String_Node_Str");
if (childUsername instanceof JsonArray && childLastName instanceof JsonArray && childFirstName instanceof JsonArray&& childClasses instanceof JsonArray&& ((JsonArray)childClasses).size() == ((JsonArray)childLastName).size() && ((JsonArray)childFirstName).size() == ((JsonArray)childLastName).size()) {
for (int j=0; j < ((JsonArray)childUsername).size(); j++) {
String mapping=structure.getExternalId() + ((JsonArray)childUsername).<String>get(j).trim() + ((JsonArray)childLastName).<String>get(j).trim()+ ((JsonArray)childFirstName).<String>get(j).trim()+ ((JsonArray)childClasses).<String>get(j).trim()+ CsvFeeder.DEFAULT_STUDENT_SEED;
relativeStudentMapping(linkStudents,mapping);
}
}
 else if (childUsername instanceof String && childLastName instanceof String && childFirstName instanceof String&& childClasses instanceof String) {
String mapping=structure.getExternalId() + childLastName.toString().trim() + childFirstName.toString().trim()+ childClasses.toString().trim()+ CsvFeeder.DEFAULT_STUDENT_SEED;
relativeStudentMapping(linkStudents,mapping);
}
 else {
handler.handle(new ResultMessage().error("String_Node_Str"));
return;
}
}
 else if ("String_Node_Str".equals(attr)) {
Object childLastName=user.getValue(attr);
Object childFirstName=user.getValue("String_Node_Str");
Object childClasses=user.getValue("String_Node_Str");
if (childLastName instanceof JsonArray && childFirstName instanceof JsonArray && childClasses instanceof JsonArray&& ((JsonArray)childClasses).size() == ((JsonArray)childLastName).size() && ((JsonArray)childFirstName).size() == ((JsonArray)childLastName).size()) {
for (int j=0; j < ((JsonArray)childLastName).size(); j++) {
String mapping=structure.getExternalId() + ((JsonArray)childLastName).<String>get(j).trim() + ((JsonArray)childFirstName).<String>get(j).trim()+ ((JsonArray)childClasses).<String>get(j).trim()+ DEFAULT_STUDENT_SEED;
relativeStudentMapping(linkStudents,mapping);
}
}
 else if (childLastName instanceof String && childFirstName instanceof String && childClasses instanceof String) {
String mapping=structure.getExternalId() + childLastName.toString().trim() + childFirstName.toString().trim()+ childClasses.toString().trim()+ DEFAULT_STUDENT_SEED;
relativeStudentMapping(linkStudents,mapping);
}
 else {
handler.handle(new ResultMessage().error("String_Node_Str"));
return;
}
}
}
importer.createOrUpdateUser(user,linkStudents);
break;
case "String_Node_Str":
importer.createOrUpdateGuest(user,classes.toArray(new String[classes.size()][2]));
break;
}
}
i++;
}
switch (profile) {
case "String_Node_Str":
importer.getPersEducNat().createAndLinkSubjects(structure.getExternalId());
break;
case "String_Node_Str":
importer.linkRelativeToClass(RELATIVE_PROFILE_EXTERNAL_ID);
importer.linkRelativeToStructure(RELATIVE_PROFILE_EXTERNAL_ID);
importer.addRelativeProperties(getSource());
break;
}
}
 catch (Exception e) {
handler.handle(new ResultMessage().error("String_Node_Str"));
log.error("String_Node_Str",e);
}
}

Fixed version (ground truth):
public void start(final String profile,final Structure structure,String file,String charset,final Importer importer,final Handler<Message<JsonObject>> handler){
  importer.createOrUpdateProfile(STUDENT_PROFILE);
  importer.createOrUpdateProfile(RELATIVE_PROFILE);
  importer.createOrUpdateProfile(PERSONNEL_PROFILE);
  importer.createOrUpdateProfile(TEACHER_PROFILE);
  importer.createOrUpdateProfile(GUEST_PROFILE);
  DefaultFunctions.createOrUpdateFunctions(importer);
  final Validator validator=ManualFeeder.profiles.get(profile);
  try {
    CSVReader csvParser=getCsvReader(file,charset);
    final List<String> columns=new ArrayList<>();
    String[] strings;
    int i=0;
    while ((strings=csvParser.readNext()) != null) {
      if (i == 0) {
        columnsMapper.getColumsNames(strings,columns,handler);
      }
 else       if (!columns.isEmpty()) {
        JsonObject user=new JsonObject();
        user.putArray("String_Node_Str",new JsonArray().add(structure.getExternalId()));
        user.putArray("String_Node_Str",new JsonArray().add(profile));
        List<String[]> classes=new ArrayList<>();
        for (int j=0; j < strings.length; j++) {
          final String c=columns.get(j);
          final String v=strings[j].trim();
          if ((v.isEmpty() && !"String_Node_Str".equals(c)) || (v.isEmpty() && "String_Node_Str".equals(c) && strings[j + 1].trim().isEmpty()))           continue;
switch (validator.getType(c)) {
case "String_Node_Str":
            if ("String_Node_Str".equals(c)) {
              Matcher m=frenchDatePatter.matcher(v);
              if (m.find()) {
                user.putString(c,m.group(3) + "String_Node_Str" + m.group(2)+ "String_Node_Str"+ m.group(1));
              }
 else {
                user.putString(c,v);
              }
            }
 else {
              user.putString(c,v);
            }
          break;
case "String_Node_Str":
        JsonArray a=user.getArray(c);
      if (a == null) {
        a=new JsonArray();
        user.putArray(c,a);
      }
    if (("String_Node_Str".equals(c) || "String_Node_Str".equals(c) || "String_Node_Str".equals(c)) && !v.startsWith(structure.getExternalId() + "String_Node_Str")) {
      a.add(structure.getExternalId() + "String_Node_Str" + v);
    }
 else {
      a.add(v);
    }
  break;
case "String_Node_Str":
user.putBoolean(c,"String_Node_Str".equals(v.toLowerCase()));
break;
default :
Object o=user.getValue(c);
final String v2;
if ("String_Node_Str".equals(c) && !v.startsWith(structure.getExternalId() + "String_Node_Str")) {
v2=structure.getExternalId() + "String_Node_Str" + v;
}
 else {
v2=v;
}
if (o != null) {
if (o instanceof JsonArray) {
((JsonArray)o).add(v2);
}
 else {
JsonArray array=new JsonArray();
array.add(o).add(v2);
user.putArray(c,array);
}
}
 else {
user.putString(c,v2);
}
}
if ("String_Node_Str".equals(c)) {
String[] cc=v.split("String_Node_Str");
if (cc.length == 2 && !cc[1].matches("String_Node_Str")) {
final String fosEId=importer.getFieldOfStudy().get(cc[1]);
if (fosEId != null) {
cc[1]=fosEId;
}
}
String eId=structure.getExternalId() + '$' + cc[0];
structure.createClassIfAbsent(eId,cc[0]);
final String[] classId=new String[3];
classId[0]=structure.getExternalId();
classId[1]=eId;
classId[2]=(cc.length == 2) ? cc[1] : "String_Node_Str";
classes.add(classId);
}
}
String ca;
long seed;
JsonArray classesA;
Object co=user.getValue("String_Node_Str");
if (co != null && co instanceof JsonArray) {
classesA=(JsonArray)co;
}
 else if (co instanceof String) {
classesA=new JsonArray().add(co);
}
 else {
classesA=null;
}
if ("String_Node_Str".equals(profile) && classesA != null && classesA.size() == 1) {
seed=defaultStudentSeed;
ca=classesA.get(0);
}
 else {
ca=String.valueOf(i);
seed=System.currentTimeMillis();
}
generateUserExternalId(user,ca,structure,seed);
if ("String_Node_Str".equals(profile)) {
studentExternalIdMapping.put(getHashMapping(user,ca,structure,seed),user.getString("String_Node_Str"));
}
switch (profile) {
case "String_Node_Str":
importer.createOrUpdatePersonnel(user,TEACHER_PROFILE_EXTERNAL_ID,user.getArray("String_Node_Str"),classes.toArray(new String[classes.size()][2]),null,true,true);
break;
case "String_Node_Str":
importer.createOrUpdatePersonnel(user,PERSONNEL_PROFILE_EXTERNAL_ID,user.getArray("String_Node_Str"),classes.toArray(new String[classes.size()][2]),null,true,true);
break;
case "String_Node_Str":
importer.createOrUpdateStudent(user,STUDENT_PROFILE_EXTERNAL_ID,null,null,classes.toArray(new String[classes.size()][2]),null,null,true,true);
break;
case "String_Node_Str":
JsonArray linkStudents=new JsonArray();
for (String attr : user.getFieldNames()) {
if ("String_Node_Str".equals(attr)) {
Object o=user.getValue(attr);
if (o instanceof JsonArray) {
for (Object c : (JsonArray)o) {
linkStudents.add(c);
}
}
 else {
linkStudents.add(o);
}
}
 else if ("String_Node_Str".equals(attr)) {
Object childUsername=user.getValue(attr);
Object childLastName=user.getValue("String_Node_Str");
Object childFirstName=user.getValue("String_Node_Str");
Object childClasses=user.getValue("String_Node_Str");
if (childUsername instanceof JsonArray && childLastName instanceof JsonArray && childFirstName instanceof JsonArray&& childClasses instanceof JsonArray&& ((JsonArray)childClasses).size() == ((JsonArray)childLastName).size() && ((JsonArray)childFirstName).size() == ((JsonArray)childLastName).size()) {
for (int j=0; j < ((JsonArray)childUsername).size(); j++) {
String mapping=structure.getExternalId() + ((JsonArray)childUsername).<String>get(j).trim() + ((JsonArray)childLastName).<String>get(j).trim()+ ((JsonArray)childFirstName).<String>get(j).trim()+ ((JsonArray)childClasses).<String>get(j).trim()+ defaultStudentSeed;
relativeStudentMapping(linkStudents,mapping);
}
}
 else if (childUsername instanceof String && childLastName instanceof String && childFirstName instanceof String&& childClasses instanceof String) {
String mapping=structure.getExternalId() + childLastName.toString().trim() + childFirstName.toString().trim()+ childClasses.toString().trim()+ defaultStudentSeed;
relativeStudentMapping(linkStudents,mapping);
}
 else {
handler.handle(new ResultMessage().error("String_Node_Str"));
return;
}
}
 else if ("String_Node_Str".equals(attr) && !user.getFieldNames().contains("String_Node_Str")) {
Object childLastName=user.getValue(attr);
Object childFirstName=user.getValue("String_Node_Str");
Object childClasses=user.getValue("String_Node_Str");
if (childLastName instanceof JsonArray && childFirstName instanceof JsonArray && childClasses instanceof JsonArray&& ((JsonArray)childClasses).size() == ((JsonArray)childLastName).size() && ((JsonArray)childFirstName).size() == ((JsonArray)childLastName).size()) {
for (int j=0; j < ((JsonArray)childLastName).size(); j++) {
String mapping=structure.getExternalId() + ((JsonArray)childLastName).<String>get(j).trim() + ((JsonArray)childFirstName).<String>get(j).trim()+ ((JsonArray)childClasses).<String>get(j).trim()+ defaultStudentSeed;
relativeStudentMapping(linkStudents,mapping);
}
}
 else if (childLastName instanceof String && childFirstName instanceof String && childClasses instanceof String) {
String mapping=structure.getExternalId() + childLastName.toString().trim() + childFirstName.toString().trim()+ childClasses.toString().trim()+ defaultStudentSeed;
relativeStudentMapping(linkStudents,mapping);
}
 else {
handler.handle(new ResultMessage().error("String_Node_Str"));
return;
}
}
}
importer.createOrUpdateUser(user,linkStudents);
break;
case "String_Node_Str":
importer.createOrUpdateGuest(user,classes.toArray(new String[classes.size()][2]));
break;
}
}
i++;
}
switch (profile) {
case "String_Node_Str":
importer.getPersEducNat().createAndLinkSubjects(structure.getExternalId());
break;
case "String_Node_Str":
importer.linkRelativeToClass(RELATIVE_PROFILE_EXTERNAL_ID);
importer.linkRelativeToStructure(RELATIVE_PROFILE_EXTERNAL_ID);
importer.addRelativeProperties(getSource());
break;
}
}
 catch (Exception e) {
handler.handle(new ResultMessage().error("String_Node_Str"));
log.error("String_Node_Str",e);
}
}