micronaut-projects / micronaut-data

Ahead of Time Data Repositories
Apache License 2.0
459 stars 196 forks source link

Latest changes on DefaultPage behaviour breaks io.micronaut.data.model.Page.map #2989

Closed bzolivereckle closed 4 days ago

bzolivereckle commented 1 week ago

Expected Behavior

The iteration over the map is processed for all elements and returns an empty page if page has no elements.

Actual Behaviour

If the page is empty the map method throws an

java.lang.IllegalStateException: Page does not contain total count. It is likely that the Pageable needs to be modified to request this information.
 at io.micronaut.data.model.DefaultPage.getTotalSize(DefaultPage.java:68)
 at io.micronaut.data.model.Page.map(Page.java:99)

Steps To Reproduce

 val page = Page.empty()
 val mapped = page.map{ it }

Environment Information

JDK 21 Windows

Example Application

No response

Version

4.5.0