From 4c0d594e99287a99043bca9cc169977fb1caced1 Mon Sep 17 00:00:00 2001 From: Looly Date: Mon, 24 Oct 2022 12:09:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DPartition=E8=AE=A1=E7=AE=97si?= =?UTF-8?q?ze=E9=99=A4=E6=95=B0=E4=B8=BA0=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- .../src/main/java/cn/hutool/core/collection/Partition.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c20eac843..9f8efdf31 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,13 @@ ------------------------------------------------------------------------------------------------------------- -# 5.8.10.M1 (2022-10-23) +# 5.8.10.M1 (2022-10-24) ### 🐣新特性 ### 🐞Bug修复 * 【db 】 修复分页时order by截断问题(issue#I5X6FM@Gitee) +* 【db 】 修复Partition计算size除数为0报错问题(pr#2677@Github) ------------------------------------------------------------------------------------------------------------- # 5.8.9 (2022-10-22) diff --git a/hutool-core/src/main/java/cn/hutool/core/collection/Partition.java b/hutool-core/src/main/java/cn/hutool/core/collection/Partition.java index b5dbdaed1..8b1075853 100644 --- a/hutool-core/src/main/java/cn/hutool/core/collection/Partition.java +++ b/hutool-core/src/main/java/cn/hutool/core/collection/Partition.java @@ -42,6 +42,10 @@ public class Partition extends AbstractList> { public int size() { // 此处采用动态计算,以应对list变 final int size = this.size; + if(0 == size){ + return 0; + } + final int total = list.size(); // 类似于判断余数,当总数非整份size时,多余的数>=1,则相当于被除数多一个size,做到+1目的 // 类似于:if(total % size > 0){length += 1;}