Program: 44624
Project: 44624
Buggy source:
private ContentObject importRole(Resource roleXmlResource,String systemUserId,String cmsRepositoryId) throws Exception {
  if (roleXmlResource == null || !roleXmlResource.exists()) {
    throw new CmsException("String_Node_Str");
  }
 else {
    String roleName=StringUtils.substringBeforeLast(roleXmlResource.getFilename(),CmsConstants.PERIOD_DELIM);
    String roleAffilitation=CmsRoleAffiliationFactory.INSTANCE.getCmsRoleAffiliationForRepository(CmsRole.valueOf(roleName),cmsRepositoryId);
    CmsOutcome<ContentObject> outcome=findRole(roleAffilitation);
    if (outcome != null && outcome.getCount() > 0) {
      if (outcome.getCount() > 1) {
        logger.warn("String_Node_Str" + roleAffilitation + "String_Node_Str");
      }
      return outcome.getResults().get(0);
    }
    logger.info("String_Node_Str",roleAffilitation);
    InputStream inputStream=null;
    try {
      inputStream=roleXmlResource.getInputStream();
      String roleXml=IOUtils.toString(inputStream,"String_Node_Str");
      roleXml=StringUtils.replace(roleXml,SYSTEM_USER_ID,systemUserId);
      roleXml=StringUtils.replace(roleXml,roleName,roleAffilitation);
      ImportConfiguration configuration=ImportConfiguration.object().persist(PersistMode.DO_NOT_PERSIST).build();
      ContentObject roleObject=importDao.importContentObject(roleXml,configuration);
      if (roleObject == null) {
        throw new CmsException("String_Node_Str");
      }
      roleObject.setSystemName(cmsRepositoryEntityUtils.fixSystemName(roleObject.getSystemName()));
      return roleObject;
    }
  finally {
      if (inputStream != null) {
        IOUtils.closeQuietly(inputStream);
      }
    }
  }
}

Fixed version (ground truth):
private ContentObject importRole(Resource roleXmlResource,String systemUserId,String cmsRepositoryId,String idOfTheRepositoryWhichRepresentsTheIdentityStore) throws Exception {
  if (roleXmlResource == null || !roleXmlResource.exists()) {
    throw new CmsException("String_Node_Str");
  }
 else {
    String roleName=StringUtils.substringBeforeLast(roleXmlResource.getFilename(),CmsConstants.PERIOD_DELIM);
    String roleAffilitation=CmsRoleAffiliationFactory.INSTANCE.getCmsRoleAffiliationForRepository(CmsRole.valueOf(roleName),cmsRepositoryId);
    CmsOutcome<ContentObject> outcome=findRole(roleAffilitation);
    if (outcome != null && outcome.getCount() > 0) {
      if (outcome.getCount() > 1) {
        logger.warn("String_Node_Str" + roleAffilitation + "String_Node_Str");
      }
      return outcome.getResults().get(0);
    }
    logger.info("String_Node_Str",roleAffilitation);
    InputStream inputStream=null;
    try {
      inputStream=roleXmlResource.getInputStream();
      String roleXml=IOUtils.toString(inputStream,"String_Node_Str");
      roleXml=StringUtils.replace(roleXml,SYSTEM_USER_ID,systemUserId);
      roleXml=StringUtils.replace(roleXml,roleName,roleAffilitation);
      roleXml=StringUtils.replace(roleXml,IDENTITY_STORE_REPOSITORY_ID,idOfTheRepositoryWhichRepresentsTheIdentityStore);
      if (StringUtils.contains(roleXml,"String_Node_Str" + cmsRepositoryId + "String_Node_Str"+ idOfTheRepositoryWhichRepresentsTheIdentityStore)) {
        roleXml=StringUtils.replace(roleXml,"String_Node_Str" + cmsRepositoryId + "String_Node_Str"+ idOfTheRepositoryWhichRepresentsTheIdentityStore,"String_Node_Str" + idOfTheRepositoryWhichRepresentsTheIdentityStore);
      }
      ImportConfiguration configuration=ImportConfiguration.object().persist(PersistMode.DO_NOT_PERSIST).build();
      ContentObject roleObject=importDao.importContentObject(roleXml,configuration);
      if (roleObject == null) {
        throw new CmsException("String_Node_Str");
      }
      roleObject.setSystemName(cmsRepositoryEntityUtils.fixSystemName(roleObject.getSystemName()));
      return roleObject;
    }
  finally {
      if (inputStream != null) {
        IOUtils.closeQuietly(inputStream);
      }
    }
  }
}