Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception handling when error occured during the rollback of organization creation failure #152

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants;
import org.wso2.carbon.identity.organization.management.service.dao.OrganizationManagementDAO;
Expand Down Expand Up @@ -155,6 +157,8 @@
*/
public class OrganizationManagerImpl implements OrganizationManager {

private static final Log LOG = LogFactory.getLog(OrganizationManagerImpl.class);

private final OrganizationManagementDAO organizationManagementDAO =
new CacheBackedOrganizationManagementDAO(new OrganizationManagementDAOImpl());

Expand All @@ -178,7 +182,12 @@
getListener().postAddOrganization(organization);
} catch (OrganizationManagementException e) {
// Rollback created organization.
deleteOrganization(organization.getId());
try {
deleteOrganization(organization.getId());
} catch (OrganizationManagementException exception) {
LOG.error("Server encountered error while delete organization as rollback of organization " +

Check warning on line 188 in components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/OrganizationManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/OrganizationManagerImpl.java#L186-L188

Added lines #L186 - L188 were not covered by tests
sadilchamishka marked this conversation as resolved.
Show resolved Hide resolved
"creation failure", exception);
}

Check warning on line 190 in components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/OrganizationManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/OrganizationManagerImpl.java#L190

Added line #L190 was not covered by tests
throw e;
}
return organization;
Expand Down
Loading