DATACMNS-615 - PageImpl now rejects a total less than the amount of items given.
PageImpl now makes sure that the total given to the constructor is never less than then number of items given to make sure we do not mask broken count calculation by creating an actually invalid instance. Related ticket: DATAMONGO-1120.
This commit is contained in:
@@ -17,6 +17,8 @@ package org.springframework.data.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Basic {@code Page} implementation.
|
||||
*
|
||||
@@ -39,6 +41,9 @@ public class PageImpl<T> extends Chunk<T> implements Page<T> {
|
||||
public PageImpl(List<T> content, Pageable pageable, long total) {
|
||||
|
||||
super(content, pageable);
|
||||
|
||||
Assert.isTrue(total >= content.size(), "Total must not be less than the number of elements given!");
|
||||
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user