From d8f1ef7f2637f0f05ceb03929895f3c927f6d4eb Mon Sep 17 00:00:00 2001 From: godotg Date: Wed, 1 Nov 2023 11:30:25 +0800 Subject: [PATCH] chore[comment]: code comment --- .../zfoo/protocol/collection/CollectionUtils.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/protocol/src/main/java/com/zfoo/protocol/collection/CollectionUtils.java b/protocol/src/main/java/com/zfoo/protocol/collection/CollectionUtils.java index 91cd63e8..35ec1246 100644 --- a/protocol/src/main/java/com/zfoo/protocol/collection/CollectionUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/collection/CollectionUtils.java @@ -97,17 +97,22 @@ public abstract class CollectionUtils { } /** - * 数组初始化长度的安全上限限制,防止反序列化异常导致内存突然升高 + * EN: The safety limit of the array initialization length prevents deserialization exceptions from causing a sudden increase in memory + * CN: 数组初始化长度的安全上限限制,防止反序列化异常导致内存突然升高 */ public static int comfortableLength(int length) { if (length >= IOUtils.BYTES_PER_MB) { - throw new ArrayStoreException(StringUtils.format("新建数组的长度[{}]超过设置的安全范围[{}]", length, IOUtils.BYTES_PER_MB)); + throw new ArrayStoreException(StringUtils.format("The length of the newly created array [{}] exceeds the set safety range [{}]" + , length, IOUtils.BYTES_PER_MB)); } return length; } /** - * 计算List和HashMap初始化合适的大小,为了安全必须给初始化的集合一个最大上限,防止反序列化一个不合法的包导致内存突然升高 + * EN: Calculate the appropriate size for HashMap initialization. For safety, a maximum limit must be given + * to the initialized collection to prevent deserialization of an illegal package from causing a sudden increase in memory. + *

+ * CN: 计算HashMap初始化合适的大小,为了安全必须给初始化的集合一个最大上限,防止反序列化一个不合法的包导致内存突然升高 */ public static int comfortableCapacity(int capacity) { return capacity < 16 @@ -241,7 +246,6 @@ public abstract class CollectionUtils { } - /** * 获取集合的最后几个元素 */