Questions / Problems with SonarQube 6.2 Metrics API

已查看 95 次
跳至第一个未读帖子

Ingmar Kellner

未读,
2017年1月9日 07:20:332017/1/9
收件人 sona...@googlegroups.com

Hi,

 

during testing of the Sonargraph SonarQube Plugin, a user detected a problem with SonarQube 6.2 metrics API. Problem does not appear in 6.1.

The Sonargraph Plugin creates metrics dynamically and calls org.sonar.api.measures.Metric.Builder.setBestValue(double d) and Metric.Builder.setWorstValue(double d).

This does not seem to work with Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY (see stacktrace below).

 

I also noticed that when I exchanged the plugin in <sonarqube-inst-dir>/extensions/plugins folder with a fix for this problem, the metric meta-data (best/worst values) did not get updated and I was still getting the same error.

Only deploying the plugin into a fresh SonarQube installation worked.

 

I am not sure if those two issues are bugs or if they are usage errors on my side.

 

Best regards,

 

Ingmar

 

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project AlarmClockMain: Infinity is not a valid double value as per JSON specification. To override this behavior, use GsonBuilder.serializeSpecialFloatingPointValues() method. -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project AlarmClockMain: Infinity is not a valid double value as per JSON specification. To override this behavior, use GsonBuilder.serializeSpecialFloatingPointValues() method.

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)

        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)

        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)

        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)

        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)

        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)

        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)

        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)

        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)

        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)

        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:483)

        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)

        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)

        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)

        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Caused by: org.apache.maven.plugin.MojoExecutionException: Infinity is not a valid double value as per JSON specification. To override this behavior, use GsonBuilder.serializeSpecialFloatingPointValues() method.

        at org.sonarsource.scanner.maven.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:36)

        at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:81)

        at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:122)

        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)

        ... 20 more

Caused by: Infinity is not a valid double value as per JSON specification. To override this behavior, use GsonBuilder.serializeSpecialFloatingPointValues() method.

[ERROR]

 

 

 

hello2morrow GmbH, Unsöldstraße 2, 80538 München, Germany. Tel: +49-89- 25557-5708
Handelsregister-Nr. HRB 194643 beim Amtsgericht München, Ust.-IdNr. DE 814332144
Geschäftsführer: Alexander v. Zitzewitz

http://www.hello2morrow.com/

emailLogo  

 twitter  linkedin  facebook

 

image001.jpg
image002.png
image003.png
image004.png

Julien Lancelot

未读,
2017年1月31日 07:51:132017/1/31
收件人 Ingmar Kellner、sona...@googlegroups.com
Hi Ingmar,

Indeed using Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY in Metric.Builder.setBestValue(double d) and setWorstValue(double d) is not allowed, and for me it makes no sense.
Moreover, metrics can allow be defined at startup, it's not possible to dynamically provide them.

Regards.

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/002601d26a72%24b24136c0%2416c3a440%24%40hello2morrow.com.
For more options, visit https://groups.google.com/d/optout.
--
Julien LANCELOT | SonarSource

Ingmar Kellner

未读,
2017年1月31日 08:12:102017/1/31
收件人 Julien Lancelot、sona...@googlegroups.com

Hi Julien,

thanks for getting back on this.
Setting those infinity values as best / worst values makes sense if you want to model something like "the higher the worse". For example "number of lines per source file". There is no best value but a worst value (Double.POSITIVE_INFINITY).
If those INFINITY values are allowed, a client of the API would not need to call Metric.Builder.setDirection(Integer d), and would not need to determine the "d" by himself (it's not all static info in my use case).
If there is a value range to be respected, it would be great if the API doc would provide that info.
I hope that clarified my expectations as a user of the API.

With "creates metrics dynamically" I meant that the metric definition is read from a resource at plugin startup and creates additional metrics based on that info.

 

Mit freundlichen Grüßen / Best regards,

 

Ingmar Kellner

回复全部
回复作者
转发
0 个新帖子