镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Fix int overflow in composite size calculations - #37556

Open
guanchengang wants to merge 1 commit into
spring-projects:mainfrom
guanchengang:fix/composite-size-overflow
Open

guanchengang wants to merge 1 commit into
spring-projects:mainfrom
guanchengang:fix/composite-size-overflow

Conversation

@guanchengang

Copy link
Copy Markdown
Contributor

Compute the combined size of CompositeCollection and CompositeMap using long arithmetic and saturate to Integer.MAX_VALUE when the result exceeds the int range. This prevents size() from overflowing into a negative value, aligning behavior with the Collection.size() and Map.size() contracts. Sizes within the int range are unchanged.

Compute the combined size of `CompositeCollection` and `CompositeMap`
using long arithmetic and saturate to `Integer.MAX_VALUE` when the
result exceeds the int range. This prevents `size()` from overflowing
into a negative value, aligning behavior with the `Collection.size()`
and `Map.size()` contracts. Sizes within the int range are unchanged.

Signed-off-by: Chengang Guan <guanchengang@qq.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants