You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Kristian Rosenvold (JIRA)" <ji...@codehaus.org> on 2012/08/18 22:10:21 UTC

[jira] (SUREFIRE-848) NPE in org.apache.maven.plugin.surefire.report.AbstractTextReporter

     [ https://jira.codehaus.org/browse/SUREFIRE-848?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Rosenvold closed SUREFIRE-848.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.13.0
         Assignee: Kristian Rosenvold

Fixed in the reporter refactoring in r1374259
                
> NPE in org.apache.maven.plugin.surefire.report.AbstractTextReporter
> -------------------------------------------------------------------
>
>                 Key: SUREFIRE-848
>                 URL: https://jira.codehaus.org/browse/SUREFIRE-848
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.x support, Maven Surefire Plugin
>    Affects Versions: 2.12
>            Reporter: Stephan Schroevers
>            Assignee: Kristian Rosenvold
>             Fix For: 2.13.0
>
>         Attachments: example.tbz
>
>
> The combination Surefire/JUnit 4 causes a {{NullPointerException}} in {{org.apache.maven.plugin.surefire.report.AbstractTextReporter}} if one has a  {{RunListener}} configured which (for whatever reason) throws an exception in its {{#testRunStarted(Description)}} method.
> I have [attached|^example.tbz] a dummy project; run {{`mvn test`}} to see the problem. The cause of this issue is that {{AbstractTextReporter}} initializes its {{testResults}} field when {{AbstractTextReporter#testSetStarting(ReportEntry)}} is called, which (it seems) doesn't happen until JUnit invokes {{RunNotifier#fireTestStarted(Description)}}. This is too late, because an exception during the invocation of {{RunNotifier#fireTestRunStarted(Description)}} causes {{AbstractTextReporter#testError(ReportEntry, String, String)}} to be invoked. The result is an NPE on line 103.
> Stacktrace:
> {noformat}
> Exception in thread "ThreadedStreamConsumer" java.lang.NullPointerException
> 	at org.apache.maven.plugin.surefire.report.AbstractTextReporter.testError(AbstractTextReporter.java:103)
> 	at org.apache.maven.plugin.surefire.report.MulticastingReporter.testError(MulticastingReporter.java:87)
> 	at org.apache.maven.plugin.surefire.report.TestSetRunListener.testError(TestSetRunListener.java:150)
> 	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:115)
> 	at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:67)
> 	at java.lang.Thread.run(Thread.java:619)
> {noformat}
> Note that this issue seems to have been the root cause of SUREFIRE-157; the [last comment|jira.codehaus.org/browse/SUREFIRE-157?focusedCommentId=197215#comment-197215] to that ticket also pointed to the late initialisation of the {{testResults}} field.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira