Sonarqube LTS (4.5.6) / Sonar java plugin 3.8 possible bug : Interface and class with same short name cause StackOverflow

148 views
Skip to first unread message

gcuisinier

unread,
Dec 31, 2015, 8:17:35 AM12/31/15
to SonarQube
Hello,

With this context :
  • An interface "MyService" in a package
  • An abstract implementation of this interface : AbstractImpl
  • A service that extends this abstract class, AND explicitly implements the interface too (not necessary in most case, but valid in java)

The sonar build with maven cause StackOverflowError.


INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.codehaus.sonar:sonar-maven-plugin:4.5.6:sonar (default-cli) on project bug-stackoverflow: null: MojoExecutionException: StackOverflowError -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.sonar:sonar-maven-plugin:4.5.6:sonar (default-cli) on project bug-stackoverflow: null

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:57)

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

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

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

at org.sonar.maven.ExceptionHandling.handle(ExceptionHandling.java:37)

at org.sonar.maven.SonarMojo.execute(SonarMojo.java:175)

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: java.lang.StackOverflowError

at com.google.common.collect.UnmodifiableIterator.<init>(UnmodifiableIterator.java:32)

at com.google.common.collect.Iterators$13.<init>(Iterators.java:1057)

at com.google.common.collect.Iterators.singletonIterator(Iterators.java:1057)

at com.google.common.collect.SingletonImmutableList.iterator(SingletonImmutableList.java:55)

at com.google.common.collect.SingletonImmutableList.iterator(SingletonImmutableList.java:34)

at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:204)

at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:199)

at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:205)

at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:199)

at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:205)

at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:199)

at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:205)

at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:199)


I've put a simple project on github to reproduce : https://github.com/gcuisinier/sonarqube-stackoverflow-bug




It's seems to be related to the "short name" somewhere. Because I can fix the build in two way :


- use fully qualified name in the implements of the AbstractImpl (see https://github.com/gcuisinier/sonarqube-stackoverflow-bug/commit/45425862c71ad1dbba9eafd8bd64618a5744eb60)

- rename the service or the interface  (see https://github.com/gcuisinier/sonarqube-stackoverflow-bug/commit/bd244fee9a7233196bd4783a918f05c8b29e2ff2)



What do you think? Is it a bug ?




Nicolas Peru

unread,
Jan 4, 2016, 5:14:33 AM1/4/16
to gcuisinier, SonarQube
Hi Gildas, 

Thanks for reporting this. I still need to investigate it deeper to understand correctly the issue (because it is an issue indeed, located in semantic of java analyser) but I am wondering about one thing : Why would you want to design things that way ? why do you need to respecify the interface in your implementation class as it is anyway inherited through the abstract class ?

Cheers,

Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


--
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/ee583df1-807d-404b-9b07-ceb4a2906829%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicolas Peru

unread,
Jan 4, 2016, 6:31:02 AM1/4/16
to gcuisinier, SonarQube
Hi, 

I struggled to reproduce it but finally this is the same as the following problem : https://jira.sonarsource.com/browse/SONARJAVA-905

You encounter the issue in your case because the .class file of the interface is not found (see the log in your README file in your sample project) and thus we resolve the wrong symbol for the interface. 

Your fixes works because we end up by not resolving (symbol MyService is unknown) instead of resolving wrongly (which is really really bad as the SO error points out ;) ) 

The fact that we don't find the dependency seems to be linked to an issue with the old maven plugin and multi modules builds. Can you precise which version of maven you are using ?   Would you be able to try a new version of the sonar maven plugin ? 

Cheers, 

Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


hik...@hikage.be

unread,
Jan 7, 2016, 1:48:48 AM1/7/16
to SonarQube, hik...@hikage.be
Hi,

Indeed, that could be the same issue.

For information, the needs of specify "implements Interface" on booth abstract and child class is an internal framework issue (reflection to check annotation, .. etc ).
I agree, that's not very good, and we should fix this too.
But that's  "java valid", so if we want to use Java 7, while having Sonar works on projects based on the internal framework, it would be nice to have this issue fix in the sonar analyser.

In intern, we use Maven 3.0.3, but I can reproduce (with my github project) with Maven 3.3.9.
I can try a new version of the analyser, but we are using sonar LTS, 4.5, so the plugin should not be tight to 5.X branch if possible.

Nicolas Peru

unread,
Jan 7, 2016, 3:17:58 AM1/7/16
to Gildas Cuisinier, SonarQube
Hi, 

Sorry I was not clear enough : the version I'm interested in is the version of sonar-maven-plugin (I suppose you run the analysis with mvn sonar:sonar) 
If this one is somehow a bit outdated it might not correctly provide the module dependency to java analyzer and so create the issue you encounter. 

As for the design : I agree 100% with you that this is a valid java 7 design and should be handled properly by the analyzer, my question was not to put that in doubt :) 
Then for last version of analyzer : they all rely on LTS version for now, so you should have no problem to latest java version and latest LTS but this won't solve your issue. 

Cheers,

Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


hik...@hikage.be

unread,
Jan 7, 2016, 3:25:52 AM1/7/16
to SonarQube, hik...@hikage.be
I am using the maven plugin version that match the LTS version I am using, so 4.5.5 at this time ( or 4.5.6 in the github project, but I am also using docker image 4.5.6 to reproduce on my mac).

Julien HENRY

unread,
Jan 7, 2016, 3:51:28 AM1/7/16
to SonarQube, hik...@hikage.be
Reply all
Reply to author
Forward
0 new messages