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

Checkstyle produces invalid XML file #5162

Closed
rnveach opened this Issue Sep 28, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@rnveach
Member

rnveach commented Sep 28, 2017

Identified at #5063 (comment) ,

patch-diff-report-tool produced the following exception when running regression with MultipleStringLiteralsCheck.

Starting diff report generation ...
patch-diff-report-tool execution started.
XML parsing is started.
Exception in thread "main" javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1722,79]
Message: Character reference "&#
	at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:604)
	at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java:83)
	at com.github.checkstyle.parser.CheckstyleReportsParser.parseXmlPortion(CheckstyleReportsParser.java:160)
	at com.github.checkstyle.parser.CheckstyleReportsParser.parse(CheckstyleReportsParser.java:132)
	at com.github.checkstyle.Main.main(Main.java:163)
Caught: groovy.lang.GroovyRuntimeException: Error: !
groovy.lang.GroovyRuntimeException: Error: !
	at diff.executeCmd(diff.groovy:344)
	at diff.executeCmd(diff.groovy:338)
	at diff$_generateDiffReport_closure3.doCall(diff.groovy:237)
	at diff.generateDiffReport(diff.groovy:220)
	at diff$generateDiffReport$4.callCurrent(Unknown Source)
	at diff.run(diff.groovy:32)

at com.github.checkstyle.parser.CheckstyleReportsParser.parse(CheckstyleReportsParser.java:132)

Is when reading the master/base report.
This is the XML file: https://nimfadora.github.io/diff5008/checkstyle-result-master.txt

The specific problem line in the XML is:

<error line="64" column="14" severity="warning" message="The String &quot;&#0;&quot; appears 3 times in the file." source="com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck"/>

The problem is in XMLLogger and showcased in our UTs at https://github.com/checkstyle/checkstyle/blob/master/src/test/java/com/puppycrawl/tools/checkstyle/XMLLoggerTest.java#L65 .

{"&#0;", "&#0;"}, //reference

We deal with pure text in our messages, not references.
&#0; should not stay as it is, but be converted to &amp;#0; This is why the XML file isn't valid.

@rnveach rnveach added the approved label Sep 28, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Sep 28, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Sep 29, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Sep 29, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Sep 29, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Sep 29, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Oct 2, 2017

romani added a commit that referenced this issue Oct 10, 2017

@rnveach rnveach added the bug label Oct 10, 2017

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Oct 10, 2017

Member

Fix was merged and marked as a bug
Fixing of escaped non-printable characters is moved to #5168 since we need XML 1.1 support to escape it correctly.

Member

rnveach commented Oct 10, 2017

Fix was merged and marked as a bug
Fixing of escaped non-printable characters is moved to #5168 since we need XML 1.1 support to escape it correctly.

@rnveach rnveach closed this Oct 10, 2017

@romani romani added this to the 8.4 milestone Oct 10, 2017

timurt added a commit to timurt/checkstyle that referenced this issue Dec 19, 2017

timurt added a commit to timurt/checkstyle that referenced this issue Dec 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment