fix: when maxSize equals to 0, an ArithmaticException will be raised

This commit is contained in:
siujamo
2025-06-04 10:39:33 +08:00
parent 94e73077cd
commit 0ff8febb47
@@ -33,8 +33,6 @@ import java.util.function.Supplier;
*/ */
public final class CollectionUtil { public final class CollectionUtil {
private static final Logger log = LoggerFactory.getLogger(CollectionUtil.class);
/** /**
* Private constructor to prevent instantiation of this utility class. * Private constructor to prevent instantiation of this utility class.
*/ */
@@ -68,7 +66,7 @@ public final class CollectionUtil {
throw new IllegalArgumentException("Collection must not be null."); throw new IllegalArgumentException("Collection must not be null.");
} }
if (maxSize < 0) { if (maxSize <= 0) {
throw new IllegalArgumentException("maxSize must greater than 0."); throw new IllegalArgumentException("maxSize must greater than 0.");
} }