java.lang.IllegalStateException: Line 32 is out of range in the file

Hi Sonar community,
We’re using

  • SonarQube server 7.1.0
  • SonarScanner 4.4.0.2170
  • Java 1.8.0_252
  • Jacoco 0.8.5
  • lombok 1.18.12
  • Gradle 5.6.4

We have a build system that generates jacoco report, that is later fed into sonar-scanner. We’re seeing following exception with classes which have auto-generated methods using lombok, though I can see that .class file has @Generated annotation.

INFO: Analysing /tmp/build/put/merge-request/server/build/jacoco/test.exec
WARN: The following class(es) did not match with execution data:
WARN: > 'com/org/bla/../ScheduledTaskResponse'
WARN: > 'com/org/bla/../ReservationWindow'
WARN: > 'com/org/bla/../MaintenanceWindow'
WARN: > 'com/org/bla/../WorkflowDefinition'
WARN: In order to have accurate coverage measures, the same class files must be used as at runtime for report generation.
...
...
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Line 32 is out of range in the file server/src/main/java/com/org/bla/../ScheduledTaskResponse.java (lines: 30)
at org.sonar.api.internal.google.common.base.Preconditions.checkState(Preconditions.java:197)
at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(DefaultCoverage.java:93)
at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.lineHits(DefaultCoverage.java:81)
...

ScheduledTaskResponse.java has 32 lines and ScheduledTaskResponse.class has 111 lines because of auto-generated code. I’m new to sonarqube, any hints are appreciated.

Thanks!
Pruthvi.

Hi Pruthvi,

Welcome to the community!

SonarQube 7.1 is past EOL. You need to upgrade at your earliest convenience and let us know if the problem persists after that. (A lot of improvements have been made since 7.1.) Your upgrade path is

7.1 -> 7.9.4 -> 8.4.1 (this last step is optional)

 
HTH,
Ann

Hi @ganncamp ,

Thank you! Because of some limitations we couldn’t upgrade to 7.9.4, but we’ve upgraded to 7.9.0.26994 and we’re still seeing the issue above. Rest of the metrics are same.

To re-iterate the issue, we have java classes with getter/setter methods being auto-generated by lombok and sonarqube throws out of range exception for those classes. We will be upgrading to 8.x in couple of weeks time, meanwhile any pointers will be helpful!

Thank you!
Pruthvi.

Hi Pruthvi,

Congrats on your upgrade! If you feel it’s relevant, I think it might be interesting to understand (in a new thread) what prevented you from going all the way to 7.9.4.

Reviewing your latest answer as well as your OP (which TBH I didn’t read closely after 7.1.0…) it seems that you’re getting an ‘out of range’ error during the processing of a coverage report?

So to be really clear, you’re

  • generating code
  • writing unit tests for that generated code
  • expecting coverage on that generated code to be reflected in the SonarQube UI?

 
Ann

Hi Ann, appreciate your quick response! Good news we have identified the issue, it’s a bug in our build system that’s messing up jacoco report causing the sonar failure.

And about upgrade, we have an infra team who maintains external softwares for maintainability purposes, we can’t upgrade until it’s supported by their infra. Soon, we’ll be upgrading to 8.x.x.

Thanks again!
-Pruthvi.

Hi Pruthvi,

I’m glad you got this sorted out. And thanks for sharing your upgrade barrier. Good to know it’s not on our side.

 
:smiley:
Ann