I think I discovered a bug with the pagination logic of Query objects.
I have a query object comments defined in my components.xml. max-results param is set to 5 and I know that I have 10 comments in the DB. I can use the following code for the rendering of a "next page" link:
Now, when I'm already browsing the second and last page, i.e. with firstResult param set to 5, a "next page" link is still there. When I click on "next page", firstResult is set to 10 and the query object returns an empty list.
I went through the Query.java code and found this implementation for isNextExists():