From fafec9d351c2e11e4d47bd83e58abd47f0efe367 Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 10 Oct 2025 17:34:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`StrBuilder`charAt=E8=B6=8A?= =?UTF-8?q?=E7=95=8C=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF=EF=BC=88pr#4094@G?= =?UTF-8?q?ithub=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../src/test/java/cn/hutool/core/text/StrBuilderTest.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83ad7dc3fe..fd63792374 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ * 【db 】 修复`SqlUtil.removeOuterOrderBy`处理没有order by的语句导致异常问题(pr#4089@Github) * 【extra 】 修复`Sftp.upload`目标路径为null时空指针问题(issue#ID14WX@Gitee) * 【ai 】 修复`AIConfigBuilder`中方法名拼写错误(pr#1382@Gitee) +* 【core 】 修复`StrBuilder`charAt越界判断错误(pr#4094@Github) ------------------------------------------------------------------------------------------------------------- # 5.8.40(2025-08-26) diff --git a/hutool-core/src/test/java/cn/hutool/core/text/StrBuilderTest.java b/hutool-core/src/test/java/cn/hutool/core/text/StrBuilderTest.java index 52f2d92223..04a277af40 100644 --- a/hutool-core/src/test/java/cn/hutool/core/text/StrBuilderTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/text/StrBuilderTest.java @@ -135,9 +135,9 @@ public class StrBuilderTest { @Test void charAtTest() { final StrBuilder helloWorld = StrBuilder.create("Hello World"); - Assertions.assertEquals(helloWorld.charAt(-1),'d'); - Assertions.assertEquals(helloWorld.charAt(0),'H'); - Assertions.assertEquals(helloWorld.charAt(10),'d'); + Assertions.assertEquals('d', helloWorld.charAt(-1)); + Assertions.assertEquals('H', helloWorld.charAt(0)); + Assertions.assertEquals('d', helloWorld.charAt(10)); Assertions.assertThrows(StringIndexOutOfBoundsException.class, () -> helloWorld.charAt(11));; } }