Skip to content

Fix NumberFormatException with very large numbers in ArrayMap#577

Merged
nedtwigg merged 2 commits into
diffplug:mainfrom
veeti:arraymap-fixes
May 26, 2026
Merged

Fix NumberFormatException with very large numbers in ArrayMap#577
nedtwigg merged 2 commits into
diffplug:mainfrom
veeti:arraymap-fixes

Conversation

@veeti
Copy link
Copy Markdown
Contributor

@veeti veeti commented May 23, 2026

Test case names containing long numbers could result in a NumberFormatException being thrown. Support arbitrarily large numbers by comparing strings.

Test case names containing long numbers could result in a
NumberFormatException being thrown. Support arbitrarily large numbers by
comparing strings.
@nedtwigg
Copy link
Copy Markdown
Member

IIUC, this helps once there are more than 2,147,483,647 snapshots.

If each snapshot has size of only 1 byte, this would be ~2Gb of snapshot data (not counting indirection). I would guess ~10GB in RAM, even if the data was only a single byte being snapshotted.

Do you have a usecase where you need this? How did you choose to work on this change?

@veeti
Copy link
Copy Markdown
Contributor Author

veeti commented May 23, 2026

I am hitting this from my Kotest suite. This reproducer should demonstrate:

class ArrayMapNumberFormatTest : DescribeSpec({
    it("a123") {}
    it("a${Long.MAX_VALUE}") {}
})

@nedtwigg
Copy link
Copy Markdown
Member

This is an excellent PR! Sorry for my earlier misunderstanding, I was reviewing on my phone, I thought you were changing the keys to be strings. This just fixes the sort order to handle large numbers, which may be part of a serial number or something like that.

@nedtwigg nedtwigg merged commit fc359bd into diffplug:main May 26, 2026
3 checks passed
@nedtwigg
Copy link
Copy Markdown
Member

Published in 3.1.1.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants