tterrag1098 / BON2

A rewrite for Immibis's bearded-octo-nemesis for ForgeGradle
GNU Lesser General Public License v3.0
182 stars 50 forks source link

Fixed 'NumberFormatException' thrown on unknown snapshot versions of MC in the gradle cache #36

Closed Matthewacon closed 5 years ago

tterrag1098 commented 7 years ago

When can this happen?

Matthewacon commented 7 years ago

Somewhere in my gradle cache there is a snapshot version of MC and because there isn't a designated game version, seeing that it is a snapshot, the version string was automatically cut to "unknown", by line 66. The code to automatically return trueor false based on whether v1 or v2 is equal to "unknown" was already there, however it was above the subString(int, int) invocation. The only modification that I made was moving the subString(int, int) calls above the if blocks at line 60

tterrag1098 commented 7 years ago

I don't see how this helps. Now it will crash on "unknown" as it will try to substring from 0 to -1.

Matthewacon commented 7 years ago

When I said that the version for the release was "unknown", I meant it still follows the convention for versioning releases: MCVER-FORGEVER, however the substring created for the MC version won't be a series of period delimited numbers because the MCVER portion of the string is actually "unknown" and not, for example, "1.7.10-FORGEVER". Moving the substring reassignment of v1 and v2 above the if blocks that check for an "unknown" version string, solves the otherwise unhandled NumberFormatException thrown when trying to parse "unknown" as a number.

tterrag1098 commented 5 years ago

I know it's been a long time, but I still don't see how this fixes the problem, unless the version string is literally "unknown-somethingelse" which I don't think is possible.

Matthewacon commented 5 years ago

I've switched systems since posting this PR and I haven't experienced this error since. I don't remember in what context this error occurred or what the steps are to reproduce it, so I'm closing the PR.