StackOverflowError at DefaultInputComponent.equals

I’m getting this error when running mvn clean verify sonar:sonar:

Exception in thread "main" java.lang.StackOverflowError
	at org.sonar.api.batch.fs.internal.DefaultInputComponent.equals(DefaultInputComponent.java:48)
	at com.google.common.collect.SingletonImmutableBiMap.get(SingletonImmutableBiMap.java:56)
	at com.google.common.collect.ImmutableListMultimap.get(ImmutableListMultimap.java:285)
	at com.google.common.collect.ImmutableListMultimap.get(ImmutableListMultimap.java:55)
	at org.sonar.scanner.scan.DefaultInputModuleHierarchy.children(DefaultInputModuleHierarchy.java:69)
	at org.sonar.scanner.scan.WorkDirectoriesInitializer.cleanAllWorkingDirs(WorkDirectoriesInitializer.java:49)
	at org.sonar.scanner.scan.WorkDirectoriesInitializer.cleanAllWorkingDirs(WorkDirectoriesInitializer.java:50)
	at org.sonar.scanner.scan.WorkDirectoriesInitializer.cleanAllWorkingDirs(WorkDirectoriesInitializer.java:50)
	at org.sonar.scanner.scan.WorkDirectoriesInitializer.cleanAllWorkingDirs(WorkDirectoriesInitializer.java:50)
	at org.sonar.scanner.scan.WorkDirectoriesInitializer.cleanAllWorkingDirs(WorkDirectoriesInitializer.java:50)
	at org.sonar.scanner.scan.WorkDirectoriesInitializer.cleanAllWorkingDirs(WorkDirectoriesInitializer.java:50)
	at org.sonar.scanner.scan.WorkDirectoriesInitializer.cleanAllWorkingDirs(WorkDirectoriesInitializer.java:50)
	at org.sonar.scanner.scan.WorkDirectoriesInitializer.cleanAllWorkingDirs(WorkDirectoriesInitializer.java:50)

This happens with both version 3.6.0.1398 and version 3.7.0.1746 of the sonar-maven-plugin. Is this a known issue? I searched but couldn’t find anything similar.

1 Like

Hi,

Could you provide a little more log context? Also, what’s the structure of your project?

 
Thx,
Ann

I figured it out after attaching my debugger. I have a multi-module Maven project, and in the root POM I had set the property <sonar.projectKey>foo</sonar.projectKey>, which then propagated into the sub-modules, of course. When WorkDirectoriesInitializer.cleanAllWorkingDirs went to recurse through the project, it calculated a key for each module, but it did this by reading the sonar.projectKey property. Because this had the same value for every module, the recursion never completed and the stack overflowed.

The fix in my case (which I found on StackOverflow, of course) was to add <sonar.moduleKey>${project.artifactId}</sonar.moduleKey> to the root POM, which evaluates to a different value for each sub-module and thereby allows the recursion to complete.

3 Likes

Thanks for the update!