-
Notifications
You must be signed in to change notification settings - Fork 968
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed support for keys that look like numbers longer than an int.
Previously such config keys would still be parsed with `Integer#parseInt`, resulting in a `NumberFormatException`. Now the number-like keys are parsed to a Long (no measures made but performance expected hit expected to be negligible) if their numbers of digits is shorter than the number of digits in `Long.MAX_VALUE`. One could have also tried to parse numbers exactly up to `Long.MAX_VALUE`, but added usability doesn't seem to match the required complexity - in fact, one could also argue that the current loop-based checking if a key looks like a number is a bit of an overkill, but I didn't want to dig into the original reason for why a regexp was not used, instead focusing on fixing an apparent bug in the most straightforward way.
- Loading branch information
1 parent
1c83360
commit f76deb6
Showing
3 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// this checks sorting map keys, where keys that look like numbers are treated differently | ||
// specifically tests very long numbers which fit neither in an Integer nor in a Long | ||
|
||
"10" = "42" | ||
sth = 42 | ||
"1" = "42" | ||
"12" = "42" | ||
"123" = "42" | ||
"1234" = "42" | ||
"12345" = "42" | ||
"123456" = "42" | ||
"1234567" = "42" | ||
"12345678" = "42" | ||
"123456789" = "42" | ||
"1234567890" = "42" | ||
"12345678901" = "42" | ||
"123456789012" = "42" | ||
"1234567890123" = "42" | ||
"12345678901234" = "42" | ||
"123456789012345" = "42" | ||
"1234567890123456" = "42" | ||
"12345678901234567" = "42" | ||
"123456789012345678" = "42" | ||
"1234567890123456789" = "42" | ||
"12345678901234567891" = "42" | ||
"123456789012345678912" = "42" | ||
"1234567890123456789123" = "42" | ||
"12345678901234567891234" = "42" | ||
"123456789012345678912345" = "42" | ||
"1234567890123456789123456" = "42" | ||
"12345678901234567891234567" = "42" | ||
"123456789012345678912345678" = "42" | ||
"1234567890123456789123456789" = "42" | ||
"12345678901234567891234567890" = "42" | ||
"123456789012345678912345678901" = "42" | ||
"1234567890123456789123456789012" = "42" | ||
"12345678901234567891234567890123" = "42" | ||
"123456789012345678912345678901234" = "42" | ||
"1234567890123456789123456789012345" = "42" | ||
"12345678901234567891234567890123456" = "42" | ||
"123456789012345678912345678901234567" = "42" | ||
"1234567890123456789123456789012345678" = "42" | ||
"12345678901234567891234567890123456789" = "42" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters