-
Notifications
You must be signed in to change notification settings - Fork 156
Description
Hello,
We use NumberSizePagingBehavior with JpaEntityRepositoryBase repository (version 3.4.20210509072026).
And recently, we have discovered the issue that totalResourcesCount is not properly computed when the requested page is greater than actually available.
I will try to describe the issue via an example:
Assume that we have 3 records in the database.
1st query /resource?page[number]=1&page[size]=2:
resourceList.getMeta(PagedMetaInformation.class).getTotalResourceCount() gives 3 (correct, value was fetched from the database).
2nd query /resource?page[number]=2&page[size]=2:
resourceList.getMeta(PagedMetaInformation.class).getTotalResourceCount() gives 3 (correct, value was not fetched from the database: link in source code )
3rd query for nonexistent page /resource?page[number]=5&page[size]=2:
resourceList.getMeta(PagedMetaInformation.class).getTotalResourceCount() gives 8 (wrong).
totalResourcesCount also was not fetched from the database and no errors occurred.
For the same situation, we are getting an error response when using QuerySpec#apply method instead of JpaEntityRepositoryBase queries:
{status=400, title=BAD_REQUEST, detail=page offset out of range, cannot move beyond data set}
In this situation, I would expect consistency with InMemoryEvaluator validation behaviour or at least properly fetched total count.