Skip to content

Assumption on numeric parts being 32-bit integers is insufficient #2

@yalinhuang

Description

@yalinhuang

It is not uncommon to attach timestamps to the "prerelease" part of package version strings. Here is an example -- https://registry.npmjs.org/puppeteer/1.3.0-next.1524774887046

The timestamp is in the unit of microsecond, and hence exceeds the boundary of Integer.MAX_VALUE. Feeding the above example into Version.from() results in this exception:

Caused by: java.lang.NumberFormatException: For input string: "1524774887046"
	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.yuchi.semver.Version.<init>(Version.java:81)
	at com.github.yuchi.semver.Version.<init>(Version.java:32)

Using Long may solve the issue. Or all numeric parts in a version string should stay in string data type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions