Program: 166354
Project: 166354
Buggy source:
/** 
 * @param userProfile
 * @return
 */
public XXPortalUser updateUser(VXPortalUser userProfile){
  XXPortalUser gjUser=daoManager.getXXPortalUser().getById(userProfile.getId());
  if (gjUser == null) {
    logger.error("String_Node_Str" + userProfile);
    return null;
  }
  checkAccess(gjUser);
  boolean updateUser=false;
  if (userProfile.getStatus() != gjUser.getStatus()) {
    updateUser=true;
  }
  String emailAddress=userProfile.getEmailAddress();
  if (stringUtil.isEmpty(emailAddress)) {
    String randomString=guidUtil.genGUID();
    userProfile.setEmailAddress(randomString);
    updateUser=true;
  }
 else {
    if (stringUtil.validateEmail(emailAddress)) {
      XXPortalUser checkUser=daoManager.getXXPortalUser().findByEmailAddress(emailAddress);
      if (checkUser != null) {
        String loginId=userProfile.getLoginId();
        if (loginId == null) {
          throw restErrorUtil.createRESTException("String_Node_Str" + "String_Node_Str",MessageEnums.INVALID_INPUT_DATA);
        }
 else         if (!loginId.equals(checkUser.getLoginId())) {
          throw restErrorUtil.createRESTException("String_Node_Str" + "String_Node_Str",MessageEnums.INVALID_INPUT_DATA);
        }
 else {
          userProfile.setEmailAddress(emailAddress);
          updateUser=true;
        }
      }
 else {
        userProfile.setEmailAddress(emailAddress);
        updateUser=true;
      }
    }
 else {
      throw restErrorUtil.createRESTException("String_Node_Str",MessageEnums.INVALID_INPUT_DATA);
    }
  }
  if (!stringUtil.isEmpty(userProfile.getFirstName()) && !userProfile.getFirstName().equals(gjUser.getFirstName())) {
    userProfile.setFirstName(stringUtil.toCamelCaseAllWords(userProfile.getFirstName()));
    updateUser=true;
  }
  if (userProfile.getLastName() != null && !userProfile.getLastName().equals(gjUser.getLastName())) {
    userProfile.setLastName(stringUtil.toCamelCaseAllWords(userProfile.getLastName()));
    updateUser=true;
  }
  if (!stringUtil.isEmpty(userProfile.getPublicScreenName()) && !userProfile.getPublicScreenName().equals(gjUser.getPublicScreenName())) {
    userProfile.setPublicScreenName(userProfile.getFirstName() + "String_Node_Str" + userProfile.getLastName());
    updateUser=true;
  }
  updateRoles(userProfile.getId(),userProfile.getUserRoleList());
  if (updateUser) {
    List<XXTrxLog> trxLogList=xPortalUserService.getTransactionLog(userProfile,gjUser,"String_Node_Str");
    userProfile.setPassword(gjUser.getPassword());
    userProfile=xPortalUserService.updateResource(userProfile);
    sessionMgr.resetUserSessionForProfiles(ContextUtil.getCurrentUserSession());
    msBizUtil.createTrxLog(trxLogList);
  }
  return gjUser;
}

Fixed version (ground truth):
/** 
 * @param userProfile
 * @return
 */
public XXPortalUser updateUser(VXPortalUser userProfile){
  XXPortalUser gjUser=daoManager.getXXPortalUser().getById(userProfile.getId());
  if (gjUser == null) {
    logger.error("String_Node_Str" + userProfile);
    return null;
  }
  checkAccess(gjUser);
  boolean updateUser=false;
  if (userProfile.getStatus() != gjUser.getStatus()) {
    updateUser=true;
  }
  String emailAddress=userProfile.getEmailAddress();
  if (stringUtil.isEmpty(emailAddress)) {
    String randomString=guidUtil.genGUID();
    userProfile.setEmailAddress(randomString);
    updateUser=true;
  }
 else {
    if (stringUtil.validateEmail(emailAddress)) {
      XXPortalUser checkUser=daoManager.getXXPortalUser().findByEmailAddress(emailAddress);
      if (checkUser != null) {
        String loginId=userProfile.getLoginId();
        if (loginId == null) {
          throw restErrorUtil.createRESTException("String_Node_Str" + "String_Node_Str",MessageEnums.INVALID_INPUT_DATA);
        }
 else         if (!loginId.equals(checkUser.getLoginId())) {
          throw restErrorUtil.createRESTException("String_Node_Str" + "String_Node_Str",MessageEnums.INVALID_INPUT_DATA);
        }
 else {
          userProfile.setEmailAddress(emailAddress);
          updateUser=true;
        }
      }
 else {
        userProfile.setEmailAddress(emailAddress);
        updateUser=true;
      }
    }
 else {
      throw restErrorUtil.createRESTException("String_Node_Str",MessageEnums.INVALID_INPUT_DATA);
    }
  }
  if (!stringUtil.isEmpty(userProfile.getFirstName()) && !userProfile.getFirstName().equals(gjUser.getFirstName())) {
    userProfile.setFirstName(stringUtil.toCamelCaseAllWords(userProfile.getFirstName()));
    updateUser=true;
  }
  if (userProfile.getLastName() != null && !userProfile.getLastName().equals(gjUser.getLastName())) {
    userProfile.setLastName(stringUtil.toCamelCaseAllWords(userProfile.getLastName()));
    updateUser=true;
  }
  if (!stringUtil.isEmpty(userProfile.getPublicScreenName()) && !userProfile.getPublicScreenName().equals(gjUser.getPublicScreenName())) {
    userProfile.setPublicScreenName(userProfile.getFirstName() + "String_Node_Str" + userProfile.getLastName());
    updateUser=true;
  }
  updateRoles(userProfile.getId(),userProfile.getUserRoleList());
  if (updateUser) {
    List<XXTrxLog> trxLogList=xPortalUserService.getTransactionLog(userProfile,gjUser,"String_Node_Str");
    userProfile.setPassword(gjUser.getPassword());
    xPortalUserService.updateResource(userProfile);
    sessionMgr.resetUserSessionForProfiles(ContextUtil.getCurrentUserSession());
    msBizUtil.createTrxLog(trxLogList);
  }
  return gjUser;
}