Skip to content

Overflow ao realizar cálculo do offset na paginação #20

Description

@VJPbr

Contexto

A lib é utilizada no projeto do JE, em um teste realizado pelo QA foi descoberto um problema no cálculo do offset.

Descrição

Em PageSpec:37:

public int getOffset() {
  return this.pageNumber * this.pageSize;
}

Quando o pageNumber é na ordem de 7 dígitos (ex: 9999999), e o pageSize 2000 (valor máximo limitado pelo spring), ocorre um overflow nesse cálculo e o retorno é negativo, entretanto, o offset não pode ser negativo.

Sugestão

Após análise feita pela equipe, entendemos que o retorno pode ser um long, evitando esse problema:

public long getOffset() {
  return this.pageNumber.longValue() * this.pageSize;
}

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions