Cannot add the same measure twice


We have troubles with sonarqube for the last two days. Our project is open-source and can be found here:

Between the last successful run and the failing run our code did not change (could be an issue with one of our dependencies?).

The error is:

Caused by: java.lang.UnsupportedOperationException: Can not add the same measure twice on publisher-sdk/src/test/java/com/criteo/publisher/model/RemoteConfigRequestTest.kt: DefaultMeasure[component=publisher-sdk/src/test/java/com/criteo/publisher/model/RemoteConfigRequestTest.kt,metric=Metric[id=<null>,key=skipped_tests,description=Number of skipped unit tests,type=INT,direction=-1,domain=Coverage,name=Skipped Unit Tests,qualitative=true,userManaged=false,enabled=true,worstValue=<null>,bestValue=0.0,optimizedBestValue=true,hidden=false,deleteHistoricalData=false,decimalScale=<null>],value=0,fromCore=false,storage=org.sonar.scanner.sensor.DefaultSensorStorage@2cb0ef27,saved=false]

Additional information:

  • versions: we are using sonarqube through Gradle plugin v3.0.
    plugins { id("org.sonarqube") version "3.0" }
  • what are you trying to achieve: trying to make ./gradlew sonarqube successful again.
  • what have you tried so far to achieve this: looked at the logs, used ./gradlew sonarqube--stacktrace. Deleted that RemoteConfigRequestTest file but the issue happens with another file.

Any help would be appreciated.

Thank you!

1 Like

Hi @Amokrane,

Sorry for the late reply. Did you update SonarQube itself recently, by any chance? And are you using a community plugin for analyzing Kotlin? As SonarQube provides Kotlin analysis out of the box, it could conflict with another plugin trying to analyze the same files.


I’m facing a similar error after updating the SonarQube server from version 8.5.1 to 8.6.0 and the only Kotlin analyzer installed is the one that’s bundled with SonarQube:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project plsql: Can not add the same measure twice on zpa-core/src/test/kotlin/org/sonar/plsqlopen/PlSqlChecksTest.kt: DefaultMeasure[component=zpa-core/src/test/kotlin/org/sonar/plsqlopen/PlSqlChecksTest.kt,metric=Metric[uuid=<null>,key=skipped_tests,description=Number of skipped unit tests,type=INT,direction=-1,domain=Coverage,name=Skipped Unit Tests,qualitative=true,userManaged=false,enabled=true,worstValue=<null>,bestValue=0.0,optimizedBestValue=true,hidden=false,deleteHistoricalData=false,decimalScale=<null>],value=0,fromCore=false,storage=org.sonar.scanner.sensor.DefaultSensorStorage@72d350c,saved=false]

In my case, I have the same src/test/kotlin/org/sonar/plsqlopen/PlSqlChecksTest.kt path on two different Maven modules (zpa-core and sonar-plsql-open-plugin). Somehow, when KotlinSurefireSensor is running on the sonar-plsql-open-plugin module, it’s trying to save the measure on the wrong file (from zpa-core module).

[INFO] Sensor KotlinSurefireSensor [kotlin]
[INFO] parsing [D:\a\1\s\zpa-core\target\surefire-reports]
[INFO] Searching for org/sonar/plsqlopen/PlSqlChecksTest

[INFO] Sensor KotlinSurefireSensor [kotlin]
[INFO] parsing [D:\a\1\s\sonar-plsql-open-plugin\target\surefire-reports]
[INFO] Searching for org/sonar/plsqlopen/PlSqlChecksTest
[ERROR] (...) Can not add the same measure twice on zpa-core/src/test/kotlin/org/sonar/plsqlopen/PlSqlChecksTest.kt

Logs attached below:
sq-8.5.txt (15.6 KB) sq-8.6.txt (30.4 KB)

I’ve added a minimal reproducible example here:

experiencing the same issue trying to use the following items in my sonarqube.settings:

sonar.python.xunit.reportPath = ./python/pytest.junit.xml # (junit results from pytest)
sonar.cxx.xunit.reportPath = **/gtest/gtest.xml # (xml based gtest results)

Either one or the other reportPath may be used and resolves correctly, but using them at the same time causes the “Can not add the same measure twice” error. I would post the full error output but it is on another computer and I can’t copy/paste.

note, the value “reportpath” is correct on these as I am running on sonarqube 7.9.1 (LTS) with C++ community plugin 1.3.1 .