diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java index 441bd3f6d..b892452d0 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java @@ -4808,7 +4808,7 @@ private Set paginateUsers(Set limit + offset, then return only the users bounded by the offset and the limit. AbstractSet usersSorted = new TreeSet<>( Comparator.comparing(org.wso2.carbon.user.core.common.User::getFullQualifiedUsername)); - if (users.size() > limit + offset) { + if (Integer.MAX_VALUE != limit && users.size() > limit + offset) { usersSorted.addAll(new ArrayList<>(sortedSet).subList(offset - 1, limit + offset - 1)); } else { // Return all the users from the offset.