Browse Source

!224 修复subList越界异常

Merge pull request !224 from movescar/v5-master
Looly 5 years ago
parent
commit
f444295bd7
1 changed files with 3 additions and 0 deletions
  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]);