Sonarcloud analysis fails intermittently

  • ALM used (Azure DevOps)
  • CI system used (Azure DevOps)
  • Sonar Scanner plugin in ADO
  • Languages of the repository = C#

We are seeing intermittent failures on PR automated scans with the error below. Do not see the same on main branch when triggered manually.

  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
	at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
	at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
##[error]at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)

Hi,

Could you share a few log lines leading up to this so we can see where in the analysis it’s failing?

 
Ann

Hi Ann,

Here you go:

Calling the SonarScanner CLI...

INFO: Scanner configuration file: C:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.30.0\classic-sonar-scanner-msbuild\sonar-scanner-4.7.0.2747\bin\..\conf\sonar-scanner.properties

INFO: Project root configuration file: C:\a\2\.sonarqube\out\sonar-project.properties

INFO: SonarScanner 4.7.0.2747

INFO: Java 11.0.10 Oracle Corporation (64-bit)

INFO: Windows Server 2019 10.0 amd64

INFO: User cache: C:\Users\AzDevOps\.sonar\cache

INFO: Scanner configuration file: C:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.30.0\classic-sonar-scanner-msbuild\sonar-scanner-4.7.0.2747\bin\..\conf\sonar-scanner.properties

INFO: Project root configuration file: C:\a\2\.sonarqube\out\sonar-project.properties

INFO: Analyzing on SonarCloud

INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)

INFO: Load global settings

INFO: Load global settings (done) | time=590ms

INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
INFO: User cache: C:\Users\AzDevOps\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=562ms
INFO: Load/download plugins (done) | time=807ms
INFO: Loaded core extensions: developer-scanner
INFO: Found an active CI vendor: 'Azure DevOps'
INFO: Load project settings for component key: 'DC-DF-Configuration-Integration'
INFO: Load project settings for component key: 'DC-DF-Configuration-Integration' (done) | time=539ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=145ms
INFO: Project key: DC-DF-Configuration-Integration
INFO: Base dir: C:\a\2\s
INFO: Working dir: C:\a\2\.sonarqube\out\.sonar
INFO: Load project branches
INFO: Load project branches (done) | time=529ms
INFO: Check ALM binding of project 'DC-DF-Configuration-Integration'
INFO: Detected project binding: BOUND
INFO: Check ALM binding of project 'DC-DF-Configuration-Integration' (done) | time=527ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=533ms
INFO: Load branch configuration
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 17.772s
INFO: Final Memory: 19M/70M
INFO: ------------------------------------------------------------------------
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution

Hi,

Sorry, but could we have the whole log from analysis command through the end of the error?

 
Thx,
Ann

Hi,

Feel free to redact as necessary.

 
Ann

Hi,

Thanks for the logs.

After a little cleanup, I see this in the failure log:

 Caused by: java.lang.IllegalStateException: closed
    at okio.RealBufferedSource.select(RealBufferedSource.kt:218)
	at okhttp3.internal.Util.readBomAsCharset(Util.kt:265)
	at okhttp3.ResponseBody.string(ResponseBody.kt:187)
 	at okio.RealBufferedSource.select(RealBufferedSource.kt:218)
 	at okhttp3.internal.Util.readBomAsCharset(Util.kt:265)
 	at okhttp3.ResponseBody.string(ResponseBody.kt:187)
    at org.sonarqube.ws.client.OkHttpResponse.content(OkHttpResponse.java:67)
	at org.sonar.scanner.bootstrap.DefaultScannerWsClient.failIfUnauthorized(DefaultScannerWsClient.java:80)

Since failIfUnauthorized is in there, I need to double-check: between success & failure, it’s the same project with the same credentials? I.e. it’s not that one project succeeds and another fails. It’s that one project sometimes succeeds and sometimes fails - always with the same analysis token / user credentials?

 
Thx,
Ann

Hi Ann,

The logs provided are for the same project and credentials. I’m using Sonarcloud service connection in ADO hence token will always be the same.

1 Like

Hi,

Thanks for confirming. I’ve flagged this for more expert attention.

 
Ann

Hi Ann,

Any updates on this?

Hey Marcus,

Could you please check if your Azure DevOps token is valid on SonarCloud side? For master we don’t make the same call as for PR-s.
Edit: Also we see that the last call was successful so I was wondering could do another check if the issue is still there?

Thanks
Csaba

Hi Csaba,

Yes, token is still valid.
Checked in ADO, it was still intermittent as of yesterday. If it’s token issue, it should fail all the time.

I’ve generated a new token, let’s see how it goes

image

Hi Marcus,

Please let me know if you see intermittent errors again with the new token.

thanks
Csaba

Hi Csaba,

No longer seeing intermittent errors using the new token. Think we are good on this issue. Thanks.

Regards,
Marcus

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.