Fail to parse the Surefire report: /build/results/junit/TEST.util.test.suite.InfrastructureTestSuite.xml

Did a successful migration from sonarqube 6.3.1 to 6.7.4

Using the gradle sonarqube plugin version 2.5

After a gradle build and running of the unit tests I’m trying to run a sonarqube scan through gradle as before the upgrade and getting the following error

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonarqube'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
        
Caused by: org.sonar.java.AnalysisException: Fail to parse the Surefire report: /extraSpace/sandbox31/JDE/build/results/junit/TEST-curam.util.test.suite.InfrastructureTestSuite.xml

Caused by: javax.xml.stream.XMLStreamException: Maximum attribute size limit (524288) exceeded
        at com.ctc.wstx.sr.StreamScanner.constructLimitViolation(StreamScanner.java:2469)
        at com.ctc.wstx.sr.StreamScanner.verifyLimit(StreamScanner.java:2462)
        at com.ctc.wstx.sr.BasicStreamReader.parseAttrValue(BasicStreamReader.java:1962)
        at com.ctc.wstx.sr.BasicStreamReader.handleNonNsAttrs(BasicStreamReader.java:3139)
        at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2968)
        at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2839)
        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1073)
        at org.codehaus.staxmate.in.SMFlatteningCursor.getNext(SMFlatteningCursor.java:115)
        at org.sonar.plugins.surefire.data.SurefireStaxHandler.parseTestResult(SurefireStaxHandler.java:94)
        at org.sonar.plugins.surefire.data.SurefireStaxHandler.parseTestCase(SurefireStaxHandler.java:74)
        at org.sonar.plugins.surefire.data.SurefireStaxHandler.parseTestCase(SurefireStaxHandler.java:60)
        at org.sonar.plugins.surefire.data.SurefireStaxHandler.stream(SurefireStaxHandler.java:50)
        at org.sonar.plugins.surefire.StaxParser.parse(StaxParser.java:63)
        at org.sonar.plugins.surefire.StaxParser.parse(StaxParser.java:55)
        at org.sonar.plugins.surefire.SurefireJavaParser.parseFiles(SurefireJavaParser.java:111)

The file it has an issue with is large in size on the order of 20 mb but there wasn’t an issue before the upgrade. Has anybody seen this error before and could they advise as to how I might go about fixing it.
Thanks.

You seem to be hitting the default size limit of attribute in the XML parser used under the hood to parse surefire reports.

The size of the file is a bit irrelevant, I suspect a (very) long name for a method or package+class+method. Would you be able to share the xml report so we have a reproducer ?
Moreover, what is the version of SonarJava installed on your sonarqube instance ?
Thanks.

Hello @briandal,
Have you found a solution for that issue?
I’m having the same problem here and I was hoping that you could have found something.
Thanks.

Note: in my case, the XML element that is causing the problem has almost 1 million characters, it’s a classpath declaration. And apparently there’s nothing I can do to shorten it.

Hello,

I’ve created a ticket to increase max allowed length of attribute.
Thanks for the feedback

1 Like

hello,
I did not understand the solution to be able to scan large files
can you tell me what to do?
Thanks