NumberFormatException for ValueResolver.getDefaultResolvers on Android
When running handlebars on Android as part of WireMock. Getting a NumberFormatException when Handlebars.Util tries to get the javaVersion(). The value is returned as a string "0.9" in Android.
static int javaVersion() { String version = System.getProperty("java.specification.version").trim(); return Integer.parseInt(version.replace(VERSION_PREFIX, "")); }
If for some reason that the Integer can't be parsed, we get a NumberFormat exception. If this is the case can a default version be provided/. Or have Value Resolver catch the exception and return the default list of MapValueResolver, JavaBeanValueResolver instead of crashing.
This has become a larger problem with older versions of Wiremock using dependencies with CVEs open against them, nessicating an upgrade which would entail the use of this version of Handlebars - which then fails due to this issue.
@jknack do you have any plan to fix this issue? It's not possible to use newer versions of this library on Android where the older versions are facing open CVEs.
The previous implementation used a property that was probably always 0. Now it uses a property that is always 0.9 if I am not mistaken. https://developer.android.com/reference/java/lang/System#getProperties()
I have made an attempt to work around this issue. Please review this PR https://github.com/jknack/handlebars.java/pull/1074.
it seems to be the same problem as #937. I'm also struggling with this problem, and I hope it gets resolved quickly.