Bug: duplicate key with different file casing (sonar scanner .NET)

Description

After changing some file names in our repo we run into the issue below. This happened after we changed just the casing of some filenames due to cross-build issue we had. It looks like the dotnet scanner on windows has issues due to case sensitivity and breaks.

This issue only happens with PR analysis and doesn’t happen with a single branch analysis.

java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.ProjectFileIndexer
	at org.sonar.core.platform.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:139)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:3[63](https://github.com/org/automationl/actions/runs/4304271659/jobs/7505992173#step:11:64))
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:[66](https://github.com/org/automation/actions/runs/4304271659/jobs/7505992173#step:11:67))
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:5[68](https://github.com/org/automation/actions/runs/4304271659/jobs/7505992173#step:11:69))
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@59309333-org.sonar.scanner.scan.filesystem.ProjectFileIndexer': Unsatisfied dependency expressed through constructor parameter 7; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@59309333-org.sonar.scanner.scan.filesystem.FileIndexer': Unsatisfied dependency expressed through constructor parameter 6; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@59309333-org.sonar.scanner.scan.filesystem.MetadataGenerator': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@59309333-org.sonar.scanner.scan.filesystem.StatusDetection': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ScmChangedFiles' defined in org.sonar.scanner.scm.ScmChangedFilesProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.scanner.scm.ScmChangedFiles]: Factory method 'provide' threw exception; nested exception is java.lang.IllegalStateException: Duplicate key D:\actions-runner\_work\automation\automationConfigMgnt\ConfigMgnt.Tests\TestServiceCollectionExtensions.cs (attempted merging values org.sonar.scm.git.ChangedFile@eebd3ba5 and org.sonar.scm.git.ChangedFile@eebd3ba5)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:13[72](https://github.com/org/automation/actions/runs/4304271659/jobs/7505992173#step:11:73))
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:5[82](https://github.com/org/automation/actions/runs/4304271659/jobs/7505992173#step:11:83))
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:12[84](https://github.com/org/automation/actions/runs/4304271659/jobs/7505992173#step:11:85))
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1245)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:4[94](https://github.com/org/automation/actions/runs/4304271659/jobs/7505992173#step:11:95))
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1172)
	at org.sonar.core.platform.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:137)
	... 20 more

Repro steps

Change the casing of a file in a new branch and run a PR analysis between the the two branches with the file with the different casing.

Known workarounds

no known workaround

Related information

  • C#/VB.NET Plugins version C# 10
  • Visual Studio version 2022
  • MSBuild / dotnet version 6.0
  • SonarScanner for .NET version (if used) 5.11
  • Operating System Windows Server 2022

Hey there.

What version of SonarQube are you using?

SonarQube 9.9

Hi @OneCyrus
Thanks a lot for the report

We have identified an issue in the case of a file rename involving only changing the case on Windows.
I have created a ticket on our side