Program: 115531
Project: 115531
Buggy source:
/** 
 * @param tenantInfoBean TenantInfoBean
 * @throws RestAPIException
 * @throws InvalidEmailException
 * @throws RegistryException
 */
public static void updateExistingTenant(org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean) throws RestAPIException, RegistryException, InvalidEmailException {
  TenantManager tenantManager=ServiceHolder.getTenantManager();
  UserStoreManager userStoreManager;
  UserRegistry configSystemRegistry=ServiceHolder.getRegistryService().getConfigSystemRegistry(tenantInfoBean.getTenantId());
  String tenantDomain=tenantInfoBean.getTenantDomain();
  int tenantId;
  try {
    tenantId=tenantManager.getTenantId(tenantDomain);
    if (tenantId == -1) {
      String errorMsg="String_Node_Str" + tenantDomain + "String_Node_Str";
      throw new InvalidDomainException(errorMsg);
    }
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + tenantDomain + "String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  Tenant tenant;
  try {
    tenant=(Tenant)tenantManager.getTenant(tenantId);
    if (tenant == null) {
      String errorMsg="String_Node_Str" + tenantId + "String_Node_Str";
      throw new TenantNotFoundException(errorMsg);
    }
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + tenantId + "String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  if (StringUtils.isBlank(tenantInfoBean.getFirstName())) {
    try {
      CommonUtil.validateName(tenantInfoBean.getFirstName(),"String_Node_Str");
    }
 catch (    Exception e) {
      String msg="String_Node_Str";
      log.error(msg,e);
      throw new RestAPIException(msg,e);
    }
  }
  if (StringUtils.isBlank(tenantInfoBean.getLastName())) {
    try {
      CommonUtil.validateName(tenantInfoBean.getLastName(),"String_Node_Str");
    }
 catch (    Exception e) {
      String msg="String_Node_Str";
      log.error(msg,e);
      throw new RestAPIException(msg,e);
    }
  }
  tenant.setAdminFirstName(tenantInfoBean.getFirstName());
  tenant.setAdminLastName(tenantInfoBean.getLastName());
  try {
    TenantMgtUtil.addClaimsToUserStoreManager(tenant);
  }
 catch (  Exception e) {
    String msg="String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  if (StringUtils.isBlank(tenantInfoBean.getEmail())) {
    try {
      CommonUtil.validateEmail(tenantInfoBean.getEmail());
    }
 catch (    Exception e) {
      String msg="String_Node_Str";
      log.error(msg,e);
      throw new InvalidEmailException(msg);
    }
    tenant.setEmail(tenantInfoBean.getEmail());
  }
  UserRealm userRealm=configSystemRegistry.getUserRealm();
  try {
    userStoreManager=userRealm.getUserStoreManager();
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + tenantDomain + "String_Node_Str"+ e.getLocalizedMessage();
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  boolean updatePassword=false;
  if (tenantInfoBean.getAdminPassword() != null && !tenantInfoBean.getAdminPassword().equals("String_Node_Str")) {
    updatePassword=true;
  }
  try {
    if (!userStoreManager.isReadOnly() && updatePassword) {
      try {
        userStoreManager.updateCredentialByAdmin(tenantInfoBean.getAdmin(),tenantInfoBean.getAdminPassword());
      }
 catch (      UserStoreException e) {
        String msg="String_Node_Str" + tenantInfoBean.getTenantDomain() + "String_Node_Str"+ e.getMessage()+ "String_Node_Str"+ tenantInfoBean.getAdmin();
        log.error(msg,e);
        throw new RestAPIException(msg,e);
      }
    }
 else {
      tenantInfoBean.setAdminPassword("String_Node_Str");
    }
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + e.getLocalizedMessage();
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  try {
    tenantManager.updateTenant(tenant);
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + tenantDomain + "String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  try {
    TenantMgtUtil.triggerUpdateTenant(ObjectConverter.convertTenantInfoBeanToCarbonTenantInfoBean(tenantInfoBean));
  }
 catch (  StratosException e) {
    String msg="String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
}

Fixed version (ground truth):
/** 
 * @param tenantInfoBean TenantInfoBean
 * @throws RestAPIException
 * @throws InvalidEmailException
 * @throws RegistryException
 */
public static void updateExistingTenant(org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean) throws RestAPIException, RegistryException, InvalidEmailException {
  TenantManager tenantManager=ServiceHolder.getTenantManager();
  UserStoreManager userStoreManager;
  UserRegistry configSystemRegistry=ServiceHolder.getRegistryService().getConfigSystemRegistry(tenantInfoBean.getTenantId());
  String tenantDomain=tenantInfoBean.getTenantDomain();
  int tenantId;
  try {
    tenantId=tenantManager.getTenantId(tenantDomain);
    if (tenantId == -1) {
      String errorMsg="String_Node_Str" + tenantDomain + "String_Node_Str";
      throw new InvalidDomainException(errorMsg);
    }
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + tenantDomain + "String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  Tenant tenant;
  try {
    tenant=(Tenant)tenantManager.getTenant(tenantId);
    if (tenant == null) {
      String errorMsg="String_Node_Str" + tenantId + "String_Node_Str";
      throw new TenantNotFoundException(errorMsg);
    }
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + tenantId + "String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  if (StringUtils.isBlank(tenantInfoBean.getFirstName())) {
    try {
      CommonUtil.validateName(tenantInfoBean.getFirstName(),"String_Node_Str");
    }
 catch (    Exception e) {
      String msg="String_Node_Str";
      log.error(msg,e);
      throw new RestAPIException(msg,e);
    }
  }
  if (StringUtils.isBlank(tenantInfoBean.getLastName())) {
    try {
      CommonUtil.validateName(tenantInfoBean.getLastName(),"String_Node_Str");
    }
 catch (    Exception e) {
      String msg="String_Node_Str";
      log.error(msg,e);
      throw new RestAPIException(msg,e);
    }
  }
  tenant.setAdminFirstName(tenantInfoBean.getFirstName());
  tenant.setAdminLastName(tenantInfoBean.getLastName());
  try {
    TenantMgtUtil.addClaimsToUserStoreManager(tenant);
  }
 catch (  Exception e) {
    String msg="String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  if (StringUtils.isBlank(tenantInfoBean.getEmail())) {
    try {
      CommonUtil.validateEmail(tenantInfoBean.getEmail());
    }
 catch (    Exception e) {
      String msg="String_Node_Str";
      log.error(msg,e);
      throw new InvalidEmailException(msg);
    }
    tenant.setEmail(tenantInfoBean.getEmail());
  }
  UserRealm userRealm=configSystemRegistry.getUserRealm();
  try {
    userStoreManager=userRealm.getUserStoreManager();
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + tenantDomain + "String_Node_Str"+ e.getLocalizedMessage();
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  boolean updatePassword=false;
  if (tenantInfoBean.getAdminPassword() != null && StringUtils.isNotEmpty(tenantInfoBean.getAdminPassword())) {
    updatePassword=true;
  }
  try {
    if (!userStoreManager.isReadOnly() && updatePassword) {
      try {
        userStoreManager.updateCredentialByAdmin(tenantInfoBean.getAdmin(),tenantInfoBean.getAdminPassword());
      }
 catch (      UserStoreException e) {
        String msg="String_Node_Str" + tenantInfoBean.getTenantDomain() + "String_Node_Str"+ e.getMessage()+ "String_Node_Str"+ tenantInfoBean.getAdmin();
        log.error(msg,e);
        throw new RestAPIException(msg,e);
      }
    }
 else {
      tenantInfoBean.setAdminPassword(null);
    }
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + e.getLocalizedMessage();
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  try {
    tenantManager.updateTenant(tenant);
  }
 catch (  UserStoreException e) {
    String msg="String_Node_Str" + tenantDomain + "String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
  try {
    TenantMgtUtil.triggerUpdateTenant(ObjectConverter.convertTenantInfoBeanToCarbonTenantInfoBean(tenantInfoBean));
  }
 catch (  StratosException e) {
    String msg="String_Node_Str";
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
}