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

Avoid ending up with negative last page in REST Data Panache #22692

Merged
merged 1 commit into from
Jan 6, 2022

Conversation

gsmet
Copy link
Member

@gsmet gsmet commented Jan 6, 2022

Fixes #20424

@gastaldi
Copy link
Contributor

gastaldi commented Jan 6, 2022

If I understood this correctly, you're replacing:

Integer.sum(pageCount, -1)

with

Math.max(Integer.sum(pageCount,-1), 0)

Comment on lines +123 to +126
creator.invokeStaticMethod(
ofMethod(Integer.class, "sum", int.class, int.class, int.class),
pageCount,
creator.load(-1)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace this snippet with the code below?

Suggested change
creator.invokeStaticMethod(
ofMethod(Integer.class, "sum", int.class, int.class, int.class),
pageCount,
creator.load(-1)),
creator.add(pageCount, creator.load(-1)),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. But frankly, I prefer avoid touching it more than necessary.

@gsmet
Copy link
Member Author

gsmet commented Jan 6, 2022

Yes, pages are 0 based. If you don't have any pages, the last page should still be 0.

@gsmet gsmet merged commit 37918d0 into quarkusio:main Jan 6, 2022
@quarkus-bot quarkus-bot bot added this to the 2.7 - main milestone Jan 6, 2022
@gsmet gsmet modified the milestones: 2.7 - main, 2.6.2.Final Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/panache area/spring Issues relating to the Spring integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"RestDataPanacheException: Failed to list the entities" when table is empty
2 participants