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

Page.empty() is still broken #3179

Closed
eahrold opened this issue Oct 15, 2024 · 0 comments · Fixed by #3180
Closed

Page.empty() is still broken #3179

eahrold opened this issue Oct 15, 2024 · 0 comments · Fixed by #3180
Assignees
Labels
type: bug Something isn't working

Comments

@eahrold
Copy link

eahrold commented Oct 15, 2024

Expected Behavior

an empty page should still be mappable.

    void "Empty Page Can be mapped Mapped"() {
        when:
        Page<String> page = Page.empty()
        def copy = page.map { it -> it }
        copy.getTotalSize()

        then:
        notThrown(Throwable.class)
    }

Actual Behaviour

It seems like some toes were dipped in the water around this issue
https://github.com/micronaut-projects/micronaut-data/pull/3142/files

but I'm guessing there's some additional context as to why it's set to null rather than 0.

return new DefaultPage<>(content, getPageable(), hasTotalSize() ? getTotalSize() : null);

    void "Broken Empty Page When Mapped"() {
        when:
        Page<String> page = Page.empty()
        def copy = page.map { it -> it }
        copy.getTotalSize()

        then:
        thrown(java.lang.IllegalStateException.class)
    }
Caused by: java.lang.IllegalStateException: Page does not contain total count. It is likely that the Pageable needs to be modified to request this information.

Steps To Reproduce

test code provided above

Environment Information

any

Example Application

No response

Version

Micronaut Data 4.9.4

@radovanradic radovanradic self-assigned this Oct 15, 2024
@radovanradic radovanradic added the type: bug Something isn't working label Oct 16, 2024
@radovanradic radovanradic linked a pull request Oct 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants