Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumberFormatException for ValueResolver.getDefaultResolvers on Android #1026

Open
kingargyle opened this issue Oct 28, 2022 · 5 comments
Open

Comments

@kingargyle
Copy link

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.

@inktomi
Copy link

inktomi commented Jul 28, 2023

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.

@vandac
Copy link

vandac commented Sep 7, 2023

@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.

@vandac
Copy link

vandac commented Sep 7, 2023

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()

@vandac
Copy link

vandac commented Sep 7, 2023

I have made an attempt to work around this issue. Please review this PR #1074.

@zmunm
Copy link

zmunm commented Nov 21, 2023

it seems to be the same problem as #937. I'm also struggling with this problem, and I hope it gets resolved quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants