Sonarcloud returnin Java OutOfMemory for golang project

Template for a good new topic, formatted with Markdown:

  • ALM used: GitHub
  • CI system used: Github Actions
  • Scanner command used when applicable: sonar-qualitygate.wait=true
  • Languages of the repository: golang
  • Error observed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 2:17.997s
INFO: Final Memory: 15M/57M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.OutOfMemoryError: Java heap space
	at java.base/java.lang.StringUTF16.compress(StringUTF16.java:161)
	at java.base/java.lang.String.<init>(String.java:4501)
	at java.base/java.lang.String.<init>(String.java:300)
	at java.base/java.nio.HeapCharBuffer.toString(HeapCharBuffer.java:653)
	at java.base/java.nio.CharBuffer.toString(CharBuffer.java:1859)
	at java.base/java.util.regex.Matcher.group(Matcher.java:649)
	at java.base/java.util.regex.Matcher.group(Matcher.java:603)
	at java.base/java.util.Scanner.findWithinHorizon(Scanner.java:1793)
	at java.base/java.util.Scanner.hasNextLine(Scanner.java:1610)
	at org.sonar.go.coverage.GoCoverSensor.parse(GoCoverSensor.java:201)
	at org.sonar.go.coverage.GoCoverSensor.lambda$execute$1(GoCoverSensor.java:81)
	at org.sonar.go.coverage.GoCoverSensor$$Lambda$913/0x00007faa9f5db7a0.accept(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.sonar.go.coverage.GoCoverSensor.execute(GoCoverSensor.java:81)
	at org.sonar.go.coverage.GoCoverSensor.execute(GoCoverSensor.java:75)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:63)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$710/0x00007faa9f519d38.run(Unknown Source)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Hey there. We started to face this issue. We are using SonarSource/sonarcloud-github-action action. I’ve tried to set SONAR_SCANNER_JAVA_OPTS: "-Xmx2048m" but nothing changed. I didn’t find any possible solution for this error.

I am not sure what exactly this erro means. Is there any possible solution for this?

Thanks

Hey there.

Believe it or not, the SonarCloud GitHub Action still uses a version of the Scanner that uses SONAR_SCANNER_OPTS instead of SONAR_SCANNER_JAVA_OPTS.

Can you try swapping the environment variable and see if it makes a difference?

Hi @Colin thanks for the fast response. It worked :pray: