Skip to content

Commit 20d15b2

Browse files
committed
Fix null pointer exception when the tenant is invalid
1 parent da6b532 commit 20d15b2

File tree

1 file changed

+4
-0
lines changed
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils

1 file changed

+4
-0
lines changed

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java

+4
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,10 @@ public static boolean isUserExist(String username) throws APIManagementException
25852585
try {
25862586
int tenantId =
25872587
ServiceReferenceHolder.getInstance().getRealmService().getTenantManager().getTenantId(tenantDomain);
2588+
if (tenantId == -1) {
2589+
throw new APIManagementException("Tenant " + tenantDomain + " not found.",
2590+
ExceptionCodes.INVALID_TENANT);
2591+
}
25882592
UserStoreManager manager =
25892593
ServiceReferenceHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
25902594
.getUserStoreManager();

0 commit comments

Comments
 (0)