From 4771078cf4b57316180e1ec96fda4f4d23c6963a Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 8 Sep 2023 23:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DtoJSONString=E5=AF=BC?= =?UTF-8?q?=E8=87=B4CPU=E4=BD=BF=E7=94=A8=E7=8E=87=E9=AB=98=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + hutool-json/src/main/java/cn/hutool/json/JSON.java | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afad2d035..9099436fd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ * 【core 】 修复DateUtil.age年龄计算问题(issue#I7XMYW@Gitee) * 【core 】 修复JSONUtil.parse()溢出问题(issue#3289@Github) * 【core 】 修复Tailer stop NPE问题(pr#1067@Gitee) +* 【json 】 修复toJSONString导致CPU使用率高的问题(issue#3297@Github) ------------------------------------------------------------------------------------------------------------- # 5.8.21(2023-07-29) diff --git a/hutool-json/src/main/java/cn/hutool/json/JSON.java b/hutool-json/src/main/java/cn/hutool/json/JSON.java index ac7dad40c..4932f1e8a 100755 --- a/hutool-json/src/main/java/cn/hutool/json/JSON.java +++ b/hutool-json/src/main/java/cn/hutool/json/JSON.java @@ -117,9 +117,7 @@ public interface JSON extends Cloneable, Serializable, IJSONTypeConverter { */ default String toJSONString(int indentFactor) throws JSONException { final StringWriter sw = new StringWriter(); - synchronized (sw.getBuffer()) { - return this.write(sw, indentFactor, 0).toString(); - } + return this.write(sw, indentFactor, 0).toString(); } /**