[GH-ISSUE #383] NumberFormatException when pharsing versions like 2.8.1414098270477 & 0.0.111111111111 #4529

Closed
opened 2026-06-13 12:42:41 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @itay-keller on GitHub (Jul 11, 2017).
Original GitHub issue: https://github.com/semver/semver/issues/383

Hi,

Where semver is trying to pharse versions like it gets a NumberFormatException:

2.8.1414098270477

Exception in thread "Thread-17" java.lang.NumberFormatException: For input string: "1414096209398"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:583)
at java.lang.Integer.parseInt(Integer.java:615)
at com.github.zafarkhaja.semver.VersionParser.parseVersionCore(VersionParser.java:289)
at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:255)
at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:195)
at com.github.zafarkhaja.semver.Version.valueOf(Version.java:265)

Originally created by @itay-keller on GitHub (Jul 11, 2017). Original GitHub issue: https://github.com/semver/semver/issues/383 Hi, Where semver is trying to pharse versions like it gets a NumberFormatException: 2.8.1414098270477 > Exception in thread "Thread-17" java.lang.NumberFormatException: For input string: "1414096209398" > at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) > at java.lang.Integer.parseInt(Integer.java:583) > at java.lang.Integer.parseInt(Integer.java:615) > at com.github.zafarkhaja.semver.VersionParser.parseVersionCore(VersionParser.java:289) > at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:255) > at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:195) > at com.github.zafarkhaja.semver.Version.valueOf(Version.java:265)
Author
Owner

@msitte commented on GitHub (Jul 11, 2017):

your number is too long for an int. you'd have to use long instead: java.lang.Long.parseLong

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

<!-- gh-comment-id:314404459 --> @msitte commented on GitHub (Jul 11, 2017): your number is too long for an int. you'd have to use long instead: java.lang.Long.parseLong https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
Author
Owner

@itay-keller commented on GitHub (Jul 11, 2017):

These are not my version numbers, but versions I stumbled upon when using semver.
Maybe semver can change parseVersionCore to use long instead of int.

<!-- gh-comment-id:314407507 --> @itay-keller commented on GitHub (Jul 11, 2017): These are not my version numbers, but versions I stumbled upon when using semver. Maybe semver can change parseVersionCore to use long instead of int.
Author
Owner

@FichteFoll commented on GitHub (Jul 11, 2017):

You are referring to a specific implementation of semver, while this repo is about the specification. Semver does not impose a maximum number for its parts (e.g int or long), however there is an issue discussing this. I'm on mobile rn, but it shouldn't be hard to find.

<!-- gh-comment-id:314423355 --> @FichteFoll commented on GitHub (Jul 11, 2017): You are referring to a specific implementation of semver, while this repo is about the specification. Semver does not impose a maximum number for its parts (e.g int or long), however there is an issue discussing this. I'm on mobile rn, but it shouldn't be hard to find.
Author
Owner

@jwdonahue commented on GitHub (Nov 28, 2017):

@itay-keller, the most likely repo's that house the code you referenced can be found here:

https://github.com/search?utf8=%E2%9C%93&q=zafarkhaja&type=

Please close this issue.

<!-- gh-comment-id:347482401 --> @jwdonahue commented on GitHub (Nov 28, 2017): @itay-keller, the most likely repo's that house the code you referenced can be found here: https://github.com/search?utf8=%E2%9C%93&q=zafarkhaja&type= Please close this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/semver#4529