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:
Oliver Gierke
2014-12-16 12:40:48 +01:00
parent c343a65632
commit 55d988e7b7
2 changed files with 13 additions and 0 deletions

View File

@@ -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;
}