Prefer Slice over Page in RepositoryItemReader

Resolves #4115
This commit is contained in:
Henning Poettker
2023-02-09 22:25:38 +01:00
committed by Mahmoud Ben Hassine
parent 4f1dc94b07
commit 523386e674
4 changed files with 20 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,9 +28,9 @@ import org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator.In
import org.springframework.batch.item.adapter.DynamicMethodInvocationException;
import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.lang.Nullable;
@@ -168,7 +168,7 @@ public class RepositoryItemReader<T> extends AbstractItemCountingItemStreamItemR
results = doPageRead();
page++;
if (results.size() <= 0) {
if (results.isEmpty()) {
return null;
}
@@ -219,7 +219,7 @@ public class RepositoryItemReader<T> extends AbstractItemCountingItemStreamItemR
invoker.setArguments(parameters.toArray());
Page<T> curPage = (Page<T>) doInvoke(invoker);
Slice<T> curPage = (Slice<T>) doInvoke(invoker);
return curPage.getContent();
}