mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add check
This commit is contained in:
@@ -245,7 +245,7 @@ public class ListUtil {
|
||||
int resultSize = list.size();
|
||||
// 每页条目数大于总数直接返回所有
|
||||
if (resultSize <= pageSize) {
|
||||
if (pageNo < (PageUtil.getFirstPageNo()+1)) {
|
||||
if (pageNo < (PageUtil.getFirstPageNo() + 1)) {
|
||||
return Collections.unmodifiableList(list);
|
||||
} else {
|
||||
// 越界直接返回空
|
||||
@@ -253,7 +253,7 @@ public class ListUtil {
|
||||
}
|
||||
}
|
||||
// 相乘可能会导致越界 临时用long
|
||||
if (((long) (pageNo-PageUtil.getFirstPageNo()) * pageSize) > resultSize) {
|
||||
if (((long) (pageNo - PageUtil.getFirstPageNo()) * pageSize) > resultSize) {
|
||||
// 越界直接返回空
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class ListUtil {
|
||||
if (startEnd[1] > resultSize) {
|
||||
startEnd[1] = resultSize;
|
||||
if (startEnd[0] > startEnd[1]) {
|
||||
return new ArrayList<>(0);
|
||||
return empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user