浏览代码

!224 修复subList越界异常

Merge pull request !224 from movescar/v5-master
Looly 5 年之前
父节点
当前提交
f444295bd7
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      hutool-core/src/main/java/cn/hutool/core/collection/ListUtil.java

+ 3 - 0
hutool-core/src/main/java/cn/hutool/core/collection/ListUtil.java

@@ -261,6 +261,9 @@ public class ListUtil {
 		final int[] startEnd = PageUtil.transToStartEnd(pageNo, pageSize);
 		if (startEnd[1] > resultSize) {
 			startEnd[1] = resultSize;
+			if (startEnd[0] > startEnd[1]) {
+			    return new ArrayList<>(0);
+			}
 		}
 
 		return list.subList(startEnd[0], startEnd[1]);