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

NPE TermColorKeywordImpl.toString #100

Open
dmercuriali opened this issue May 31, 2019 · 2 comments
Open

NPE TermColorKeywordImpl.toString #100

dmercuriali opened this issue May 31, 2019 · 2 comments

Comments

@dmercuriali
Copy link
Contributor

Got an error in production on TermColorKeywordImpl.toString

Caused by: java.lang.NullPointerException
at cz.vutbr.web.csskit.TermColorKeywordImpl.toString(TermColorKeywordImpl.java:36)
at cz.vutbr.web.csskit.antlr4.CSSParserVisitorImpl.visitValuepart(CSSParserVisitorImpl.java:996)
at cz.vutbr.web.csskit.antlr4.CSSParserVisitorImpl.visitTermValuePart(CSSParserVisitorImpl.java:854)
at cz.vutbr.web.csskit.antlr4.CSSParserVisitorImpl.visitTerms(CSSParserVisitorImpl.java:821)
at cz.vutbr.web.csskit.antlr4.CSSParserVisitorImpl.visitDeclaration(CSSParserVisitorImpl.java:730)
at cz.vutbr.web.csskit.antlr4.CSSParserVisitorImpl.visitDeclarations(CSSParserVisitorImpl.java:691)
at cz.vutbr.web.csskit.antlr4.CSSParserVisitorImpl.visitRuleset(CSSParserVisitorImpl.java:668)
at cz.vutbr.web.csskit.antlr4.CSSParserVisitorImpl.visitStatement(CSSParserVisitorImpl.java:282)
at cz.vutbr.web.csskit.antlr4.CSSParserVisitorImpl.visitStylesheet(CSSParserVisitorImpl.java:241)
at cz.vutbr.web.csskit.antlr4.CSSParserFactory.parse(CSSParserFactory.java:206)
at cz.vutbr.web.csskit.antlr4.CSSParserFactory.parseAndImport(CSSParserFactory.java:147)
at cz.vutbr.web.csskit.antlr4.CSSParserFactory.parse(CSSParserFactory.java:72)
at cz.vutbr.web.csskit.antlr4.CSSParserFactory.parse(CSSParserFactory.java:93)
at cz.vutbr.web.css.CSSFactory.parseString(CSSFactory.java:546)
at cz.vutbr.web.css.CSSFactory.parseString(CSSFactory.java:521)

We are still on version 3.2, but the interested code looks the same (the code at CSSParserVisitorImpl.java:996 was moved in a new method CSSParserVisitorImpl#findSpecificType but the code is actually the same).

We couldn't reproduce the error and it seems that TermColorKeywordImpl#keyword should never be null.

I'll submit a pull request adding some ifs around debug statements. This won't solve the root problem but will avoid a crash on a debug statement (and avoid some string allocation).

dmercuriali added a commit to dmercuriali/jStyleParser that referenced this issue May 31, 2019
@dmercuriali
Copy link
Contributor Author

Pull request #101

@radkovo
Copy link
Owner

radkovo commented Jun 25, 2019

The problem seems to be somewhere in the parser code (e.g. CSSParserVisitorImpl). The parser implementation has changed significantly in the last release. I suggest the following approach (which should be always used when reporting a bug in any project):

  • First, verify whether the bug is still present in the latest release (jStyleParser 3.3).
  • If yes, try to reproduce the bug: in this case, try to find the CSS code that causes the NPE.
  • Then, report the issue with the related information attached and/or create a PR that fixes the bug in its origin.

Many thanks!

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

2 participants