spring-projects / spring-projects/spring-data-commons

Pageable fails when page size is 1 and 1 row returned by query [DATACMNS-1634]

Open
#2,060 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 30, 2020.

type: bug
Dominant language
Java
Stars
838
Forks
730
PR merge metrics
No merged PRs in 30d

Description

Branko opened DATACMNS-1634 and commented

When there is only one row to return from a query, and a page size is set to 1, an exception is thrown in org.springframework.data.repository.support.PageableExecutionUtils line 62. The exception is actually thrown as java.lang.NumberFormatException because a non-numeric string value (the actual result of the query) is attempted to be converted to Long, which of course leads to NumberFormatException. Perhaps, the condition in line 58 of PageableExecutionUtils should be changed from

if (pageable.isUnpaged() || pageable.getPageSize() > content.size()) {

 

to

 

if (pageable.isUnpaged() || pageable.getPageSize() >= content.size()) {

because this works correctly when page size is given as higher than the number of returned rows.

 


No further details from DATACMNS-1634

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.