IntelliJ SonarLint Plugin: Failed to update project

Versions

  • SonarQube: 8.9.2.46101
  • IntelliJ: 2021.2.2 (Runtime version 11.0.12)
  • SonarLint Plugin: 6.0.0.37696

error observed

I tried to bind a new project and got the following error:

grafik

But even after updating the server bindings I get this message. Which is quite interesting since I chose the project from the project list.

steps to reproduce

I tried to analyze what’s going wrong and got the hint that there is a Verbose Output option for the Log window. So I enabled it and got the following:

Project 'a' in server binding 'SonarQube' updated
GET 200 https://…/sonarqube/api/qualityprofiles/search.protobuf?project=b | response time=37ms
Downloaded project quality profiles in 37ms
GET 200 https://…/sonarqube/api/settings/values.protobuf?component=b | response time=24ms
Downloaded settings in 25ms
Page downloaded in 27ms
GET 200 https://…/sonarqube/batch/issues?key=b | response time=24ms
null
java.lang.NullPointerException
	at java.base/java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:108)
	at org.sonarlint.intellij.http.ApacheHttpResponse.bodyAsStream(ApacheHttpResponse.kt:35)
	at org.sonarlint.intellij.http.ApacheHttpResponse.bodyAsStream(ApacheHttpResponse.kt:26)
	at org.sonarsource.sonarlint.core.serverapi.issue.IssueApi.lambda$downloadAllFromBatchIssues$4(IssueApi.java:121)
	at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.processTimed(ServerApiHelper.java:221)
	at org.sonarsource.sonarlint.core.serverapi.issue.IssueApi.downloadAllFromBatchIssues(IssueApi.java:113)
	at org.sonarsource.sonarlint.core.container.connected.update.IssueDownloader.download(IssueDownloader.java:79)
	at org.sonarsource.sonarlint.core.container.connected.update.perform.ServerIssueUpdater.updateServerIssues(ServerIssueUpdater.java:52)
	at org.sonarsource.sonarlint.core.container.connected.update.perform.ProjectStorageUpdateExecutor.updateServerIssues(ProjectStorageUpdateExecutor.java:102)
	at org.sonarsource.sonarlint.core.container.connected.update.perform.ProjectStorageUpdateExecutor.lambda$update$0(ProjectStorageUpdateExecutor.java:62)
	at org.sonarsource.sonarlint.core.client.api.util.FileUtils.replaceDir(FileUtils.java:233)
	at org.sonarsource.sonarlint.core.container.connected.update.perform.ProjectStorageUpdateExecutor.update(ProjectStorageUpdateExecutor.java:60)
	at org.sonarsource.sonarlint.core.container.connected.ConnectedContainer.updateProject(ConnectedContainer.java:140)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.updateProject(ConnectedSonarLintEngineImpl.java:286)
	at org.sonarlint.intellij.tasks.BindingStorageUpdateTask.updateProject(BindingStorageUpdateTask.java:181)
	at org.sonarlint.intellij.tasks.BindingStorageUpdateTask.updateProjects(BindingStorageUpdateTask.java:157)
	at org.sonarlint.intellij.tasks.BindingStorageUpdateTask.run(BindingStorageUpdateTask.java:110)
	at org.sonarlint.intellij.tasks.BindingStorageUpdateTask$2.run(BindingStorageUpdateTask.java:85)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:450)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:117)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:510)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:243)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:183)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:170)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:243)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:829)

SonarQube sends a 200, but an NPE is thrown? Interesting. So I opened a browser and hit that URL and got a response: a 0 byte “issues” file. This project has no issues.

potential workaround

Unbind the project?

I’m not sure, but quite convinced, that there is a bug receiving a 0 byte file from SonarQube. Might that be possible?

The sonarlint-intellij plugin extracts the bodyBytes of the response and uses it as constructor parameter for ByteArrayInputStream.
I guess the bodyBytes are null. I tried to verify in the HttpClient5 source code that an empty server response would lead to a null bodyBytes member. But I wasn’t able to figure this out, I was not able to find the place(s) where responses are received and the corresponding objects built.

Hello,

Welcome to the community and thanks for raising this issue.

I am not able to reproduce, it works on my side if there is no issue on the server. But indeed your analysis is correct and bodyBytes is nullable, so I think in certain cases it can cause an exception.

I created this ticket to fix the problem.

Thanks again for reporting!

Thanks for investigating on this. It’s puzzling me that you can’t reproduce this. But I’m absolutely fine waiting for this change.

Hello, FYI version 6.2.0.39326 which includes a fix for the aforementioned issue has just been published to the JetBrains plugin repository.

Works now. Thank you very much!

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