Program: 35654
Project: 35654
Buggy source:
@Override public Object create(User executingUser,PropertyMap properties){
  User userToPersist=null;
  User userFound=null;
  OrgUnitProfile orgUnitProfileToPersist=null;
  OrgUnitProfile orgUnitProfileFound=null;
  int id=(Integer)properties.get("String_Node_Str");
  String email=properties.get("String_Node_Str");
  String name=properties.get("String_Node_Str");
  String firstName=properties.get("String_Node_Str");
  String locale=properties.get("String_Node_Str");
  String password=properties.get("String_Node_Str");
  int orgUnitId=(Integer)properties.get("String_Node_Str");
  List<Integer> profilesIds=properties.get("String_Node_Str");
  if (email != null && name != null) {
    userFound=em.find(User.class,id);
    if (userFound != null) {
      if (userUnitDAO.doesOrgUnitProfileExist(userFound))       orgUnitProfileFound=userUnitDAO.findOrgUnitProfileByUser(userFound);
    }
    userToPersist=UserDAOImpl.createNewUser(email,name,locale);
    userToPersist.setFirstName(firstName);
    userToPersist.setOrganization(executingUser.getOrganization());
    if (password != null && !password.isEmpty()) {
      userToPersist.setHashedPassword(PasswordHelper.hashPassword(password));
      userToPersist.setChangePasswordKey(null);
      userToPersist.setDateChangePasswordKeyIssued(new Date());
    }
    if (userFound != null && userFound.getId() > 0) {
      userToPersist.setId(userFound.getId());
      userToPersist=em.merge(userToPersist);
    }
 else {
      if (!userDAO.doesUserExist(email)) {
        userDAO.persist(userToPersist);
        try {
          log.debug("String_Node_Str" + userToPersist.getEmail());
          log.debug("String_Node_Str" + this.properties.getProperty(KEY_NEWUSER_CONFIRM_URL,DEFAULT_CONFIRM_URL));
          String confirmUrl=this.properties.getProperty(KEY_NEWUSER_CONFIRM_URL,DEFAULT_CONFIRM_URL);
          inviteMailer.send(new Invitation(userToPersist,executingUser,confirmUrl),LocaleHelper.getLocaleObject(executingUser),true);
        }
 catch (        Exception e) {
          log.debug("String_Node_Str");
          log.debug(e.getMessage());
          System.out.println(e.getStackTrace());
        }
      }
 else {
        return null;
      }
    }
    if (userToPersist.getId() > 0) {
      if (userFound != null && userFound.getId() > 0 && orgUnitProfileFound != null)       orgUnitProfileToPersist=orgUnitProfileFound;
 else       orgUnitProfileToPersist=new OrgUnitProfile();
      OrgUnit orgUnit=em.find(OrgUnit.class,orgUnitId);
      if (orgUnit != null) {
        orgUnitProfileToPersist.setOrgUnit(orgUnit);
        List<Profile> profilesToPersist=new ArrayList<Profile>();
        for (        int profileId : profilesIds) {
          Profile profile=em.find(Profile.class,profileId);
          profilesToPersist.add(profile);
        }
        orgUnitProfileToPersist.setProfiles(profilesToPersist);
        orgUnitProfileToPersist.setUser(userToPersist);
        if (userFound != null && userFound.getId() > 0 && orgUnitProfileFound != null) {
          orgUnitProfileToPersist=em.merge(orgUnitProfileToPersist);
        }
 else {
          em.persist(orgUnitProfileToPersist);
        }
        if (orgUnitProfileToPersist.getId() != 0) {
          userToPersist.setOrgUnitWithProfiles(orgUnitProfileToPersist);
        }
      }
    }
  }
  UserDTO userPersisted=null;
  if (userToPersist != null) {
    userPersisted=GetUsersWithProfilesHandler.mapUserToUserDTO(userToPersist,mapper);
    userPersisted.setIdd(userToPersist.getId());
  }
  return userPersisted;
}

Fixed version (ground truth):
@Override public Object create(User executingUser,PropertyMap properties){
  User userToPersist=null;
  User userFound=null;
  OrgUnitProfile orgUnitProfileToPersist=null;
  OrgUnitProfile orgUnitProfileFound=null;
  int id=(Integer)properties.get("String_Node_Str");
  String email=properties.get("String_Node_Str");
  String name=properties.get("String_Node_Str");
  String firstName=properties.get("String_Node_Str");
  String locale=properties.get("String_Node_Str");
  String password=properties.get("String_Node_Str");
  int orgUnitId=(Integer)properties.get("String_Node_Str");
  List<Integer> profilesIds=properties.get("String_Node_Str");
  if (email != null && name != null) {
    userFound=em.find(User.class,id);
    if (userFound != null) {
      if (userUnitDAO.doesOrgUnitProfileExist(userFound))       orgUnitProfileFound=userUnitDAO.findOrgUnitProfileByUser(userFound);
    }
    userToPersist=UserDAOImpl.createNewUser(email,name,locale);
    userToPersist.setFirstName(firstName);
    userToPersist.setOrganization(executingUser.getOrganization());
    if (password != null && !password.isEmpty()) {
      userToPersist.setHashedPassword(PasswordHelper.hashPassword(password));
      userToPersist.setChangePasswordKey(null);
      userToPersist.setDateChangePasswordKeyIssued(new Date());
    }
    if (userFound != null && userFound.getId() > 0) {
      userToPersist.setId(userFound.getId());
      userToPersist=em.merge(userToPersist);
    }
 else {
      if (!userDAO.doesUserExist(email)) {
        userDAO.persist(userToPersist);
        try {
          log.debug("String_Node_Str" + userToPersist.getEmail());
          log.debug("String_Node_Str" + this.properties.getProperty(KEY_HOST_URL,DEFAULT_HOST_URL));
          String confirmUrl=this.properties.getProperty(KEY_HOST_URL,DEFAULT_HOST_URL);
          inviteMailer.send(new Invitation(userToPersist,executingUser,confirmUrl),LocaleHelper.getLocaleObject(executingUser),true);
        }
 catch (        Exception e) {
          log.debug("String_Node_Str");
          log.debug(e.getMessage());
          System.out.println(e.getStackTrace());
        }
      }
 else {
        return null;
      }
    }
    if (userToPersist.getId() > 0) {
      if (userFound != null && userFound.getId() > 0 && orgUnitProfileFound != null)       orgUnitProfileToPersist=orgUnitProfileFound;
 else       orgUnitProfileToPersist=new OrgUnitProfile();
      OrgUnit orgUnit=em.find(OrgUnit.class,orgUnitId);
      if (orgUnit != null) {
        orgUnitProfileToPersist.setOrgUnit(orgUnit);
        List<Profile> profilesToPersist=new ArrayList<Profile>();
        for (        int profileId : profilesIds) {
          Profile profile=em.find(Profile.class,profileId);
          profilesToPersist.add(profile);
        }
        orgUnitProfileToPersist.setProfiles(profilesToPersist);
        orgUnitProfileToPersist.setUser(userToPersist);
        if (userFound != null && userFound.getId() > 0 && orgUnitProfileFound != null) {
          orgUnitProfileToPersist=em.merge(orgUnitProfileToPersist);
        }
 else {
          em.persist(orgUnitProfileToPersist);
        }
        if (orgUnitProfileToPersist.getId() != 0) {
          userToPersist.setOrgUnitWithProfiles(orgUnitProfileToPersist);
        }
      }
    }
  }
  UserDTO userPersisted=null;
  if (userToPersist != null) {
    userPersisted=GetUsersWithProfilesHandler.mapUserToUserDTO(userToPersist,mapper);
    userPersisted.setIdd(userToPersist.getId());
  }
  return userPersisted;
}