-
Notifications
You must be signed in to change notification settings - Fork 84
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
Invalid JSON when used with Java environment variables #65
Comments
That sounds pretty good, since this isn't the first time the javadetect module has failed us. Providing better error messages is always a good first step.
Did you modify this module for that fix? Or is in your Gruntfile or some other place? The former would be bad, the latter seems okay. |
I'll open a PR in a couple of days when I get time.
I modified my Gruntfile to check for |
For reference, the error can be reproduced as follows: $ JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" grunt htmllint:valid
Running "htmllint:valid" (htmllint) task
Fatal error: Unexpected token P |
Closing due to inactivity / lack of interest. |
This is still causing issues - would really appreciate a fix. |
Our builds are done in a Docker container and this has several environment variables set including
JAVA_TOOL_OPTIONS
. Sadly this causes Java to print a message on stderr. When grunt-html reads from stderr and tries to parse the JSON, it throws a "helpful" exception likeUnexpected token P
without a stack trace. It seems that this Java notice can't be disabled.You can test by running
JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" java
in your shell. You should seePicked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
followed by the help. There is an openjdk issue for this https://bugs.openjdk.java.net/browse/JDK-8039152.What would be nice is to provide better error handling so that a user can easily tell that the Java validator isn't returning valid JSON. I think that this is probably worth doing. I can make a PR if you like.
We could also test for this message and strip it before parsing but I'm not sure that you want a hack for something this although it should help it be more universal.
I have worked around this by removing this environment variable from
process.env
and this prevents it being passed to spawned processes too. With this fix, I have no problems so feel free to just close this if you like.I recently converted one of our projects to use grunt-html instead of grunt-validate-html. Its working great - thanks.
The text was updated successfully, but these errors were encountered: