Unable to run check class - Failed to write to cache for file

Make sure to tell us:

  • What version are you upgrading from?

8.9 → 9.9

  • System information (Operating system, Java version, Database provider/version)
  • Java Version - 17
  • Sonar Server - Developer edition
  • Sonar Scanner - v5
  • OS - Linux 4.19.0-24-amd64 amd64
  • What’s the issue you’re facing?

For our Java based projects on P.R the scans are using the cache, which has sped up P.Rs dramatically.

When running off our main branch (master), it throws a tonne of errors, like below. Do we need to set sonar.java.skipUnchanged=false when running off our main branch?

ERROR: Unable to run check class org.sonar.java.checks.security.ExcessiveContentRequestCheck - S5693 on file 'src/java/com/cartrawler/dc/trans/bookRetry/IRetryBookingConfigurable.java', To help improve the SonarSource Java Analyzer, please report this problem to SonarSource: see https://community.sonarsource.com/
org.sonar.java.AnalysisException: Failed to write to cache for file src/java/com/cartrawler/dc/trans/bookRetry/IRetryBookingConfigurable.java
	at org.sonar.java.checks.security.ExcessiveContentRequestCheck.writeForNextAnalysis(ExcessiveContentRequestCheck.java:323)
	at org.sonar.java.checks.security.ExcessiveContentRequestCheck.leaveFile(ExcessiveContentRequestCheck.java:201)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.lambda$scanFile$3(VisitorsBridge.java:417)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.lambda$forEach$9(VisitorsBridge.java:468)
	at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:265)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.forEach(VisitorsBridge.java:468)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.scanFile(VisitorsBridge.java:417)
	at org.sonar.java.model.VisitorsBridge.lambda$runScanner$1(VisitorsBridge.java:260)
	at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:265)
	at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:260)
	at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:243)
	at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:132)
	at org.sonar.java.JavaFrontend.scanAsBatchCallback(JavaFrontend.java:247)
	at org.sonar.java.JavaFrontend.lambda$scanBatch$0(JavaFrontend.java:238)
	at org.sonar.java.model.JParserConfig$Batch$1.acceptAST(JParserConfig.java:181)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1143)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:739)
	at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1049)
	at org.sonar.java.model.JParserConfig$Batch.parse(JParserConfig.java:165)
	at org.sonar.java.JavaFrontend.scanBatch(JavaFrontend.java:238)
	at org.sonar.java.JavaFrontend.scanInBatches(JavaFrontend.java:228)
	at org.sonar.java.JavaFrontend.scanAsBatch(JavaFrontend.java:195)
	at org.sonar.java.JavaFrontend.scan(JavaFrontend.java:170)
	at org.sonar.plugins.java.JavaSensor.execute(JavaSensor.java:113)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
	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)
	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:568)
	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: java.lang.IllegalArgumentException: Cache already contains key 'java:S5693:com.cartrawler:otaserver:src/java/com/cartrawler/dc/trans/bookRetry/IRetryBookingConfigurable.java'
	at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
	at org.sonar.scanner.cache.WriteCacheImpl.checkKey(WriteCacheImpl.java:105)
	at org.sonar.scanner.cache.WriteCacheImpl.write(WriteCacheImpl.java:62)
	at org.sonar.java.caching.JavaWriteCacheImpl.write(JavaWriteCacheImpl.java:46)
	at org.sonar.java.checks.security.ExcessiveContentRequestCheck.writeF

Hi,

That flag won’t help. You’re encountering errors in the underlying analysis. Ideally (from our perspective) you would create a new thread for each unique rule Id error (e.g. S5693 from the log snipped you’ve provided`) but since you’re getting lot of errors, I understand that that’s a lot to ask.

Are you comfortable sharing the contents of IRetryBookingConfigurable.java?

 
Ann