naver/cover-checker

NullPointerException when parsing multiple Cobertura files

Closed this issue · 1 comments

I've started debugging this.

It turns out it's a multi-threading race:

  • The parsing of two files is concurrent and starts on two separate threads.
  • Both threads, however call the parse method on the same XmlCoverageReportParser object.
  • There is a race condition where one thread thread calls CoberturaCoverageReportHandler.endElement after a </class>.
    • This ends up setting lineReports = null;
  • Another thread, still processing a class calls the initLine handler and raises a NullPointerException here lineReports.add(lineCoverageReport); since lineReports is null.

I'm not entirely sure what the best way to fix this bug would be given the current code.

I have a fix in the works that involves creating separate CoverageReportParser objects.
With the opportunity, I am also extending the functionality of the command line tool to optionally allow specifying multiple -type arguments, so these can be of different report kinds.

This is a requirement I have as I'm merging reports from multiple programming languages where some output JaCoCo reports and some output Cobertura reports.

I still need to make a few improvements, but this is the change in the works: amunra#2.

I will raise a PR when ready.

Let me know if there's specific linting and/or tooling I should run before submitting my PR.