DATACMNS-1750 - Refrain from inspecting Page contents if first item is null.
This commit is contained in:
@@ -116,7 +116,7 @@ public class PageImpl<T> extends Chunk<T> implements Page<T> {
|
||||
String contentType = "UNKNOWN";
|
||||
List<T> content = getContent();
|
||||
|
||||
if (content.size() > 0) {
|
||||
if (!content.isEmpty() && content.get(0) != null) {
|
||||
contentType = content.get(0).getClass().getName();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test;
|
||||
* Unit test for {@link PageImpl}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
class PageImplUnitTests {
|
||||
|
||||
@@ -185,4 +186,13 @@ class PageImplUnitTests {
|
||||
assertThat(page.hasPrevious()).isFalse();
|
||||
assertThat(page.hasNext()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1750
|
||||
void toStringShouldNotInspectNullInstances() {
|
||||
|
||||
Page<Integer> page = new PageImpl<>(Collections.singletonList(null));
|
||||
|
||||
assertThat(page).hasToString("Page 1 of 1 containing UNKNOWN instances");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user