Metaspace OOM Error from Jenkins call after updating from 8.5.1 to 9.8.0

I have been facing the issue since I updated last week, with a single Jenkins pipeline. The rest are fine.

Everything is running under Kubernetes. If I downgrade to SonarQube version 8.5.1 the pipeline is again working.

Full log of a given step in a pipeline:

19:08:16  + ./gradlew sonar --stacktrace -x testCoverage
19:08:17  
19:08:17  > Task :openApiGenerate
19:08:17  Successfully generated code to task ':openApiGenerate' property 'outputDir'
19:08:18  
19:08:18  > Task :generateEffectiveLombokConfig UP-TO-DATE
19:08:18  > Task :processResources UP-TO-DATE
19:08:18  > Task :generateTestFixturesEffectiveLombokConfig UP-TO-DATE
19:08:18  > Task :generateTestEffectiveLombokConfig UP-TO-DATE
19:08:18  > Task :compileKotlin
19:08:20  > Task :compileJava
19:08:20  > Task :classes
19:08:20  > Task :inspectClassesForKotlinIC UP-TO-DATE
19:08:20  > Task :jar UP-TO-DATE
19:08:20  > Task :compileTestFixturesKotlin UP-TO-DATE
19:08:20  > Task :compileTestFixturesJava NO-SOURCE
19:08:20  > Task :compileTestKotlin UP-TO-DATE
19:08:20  > Task :compileTestJava UP-TO-DATE
19:08:46  Daemon will be stopped at the end of the build after running out of JVM memory
19:08:49  > Task :sonar
19:08:50  > Task :sonar FAILED
19:08:50  
19:08:50  FAILURE: Build failed with an exception.
19:08:50  
19:08:50  * What went wrong:
19:08:50  Execution failed for task ':sonar'.
19:08:50  > Metaspace
19:08:50  
19:08:50  * Try:
19:08:50  > Run with --info or --debug option to get more log output.
19:08:50  > Run with --scan to get full insights.
19:08:50  
19:08:50  * Exception is:
19:08:50  org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonar'.
19:08:50  	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:145)
19:08:50  	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
19:08:50  	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:143)
19:08:50  	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131)
19:08:50  	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
19:08:50  	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
19:08:50  	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
19:08:50  	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
19:08:50  	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
19:08:50  	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
19:08:50  	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
19:08:50  	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
19:08:50  	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
19:08:50  	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
19:08:50  	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
19:08:50  	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
19:08:50  	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
19:08:50  	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
19:08:50  	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
19:08:50  	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
19:08:50  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
19:08:50  	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
19:08:50  	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
19:08:50  	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402)
19:08:50  	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389)
19:08:50  	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382)
19:08:50  	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368)
19:08:50  	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
19:08:50  	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
19:08:50  	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
19:08:50  	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
19:08:50  	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
19:08:50  	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
19:08:50  	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
19:08:50  Caused by: java.lang.OutOfMemoryError: Metaspace
19:08:50  
19:08:50  
19:08:50  * Get more help at https://help.gradle.org
19:08:50  
19:08:50  Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
19:08:50  
19:08:50  You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
19:08:50  
19:08:50  See https://docs.gradle.org/7.3/userguide/command_line_interface.html#sec:command_line_warnings
19:08:50  
19:08:50  BUILD FAILED in 34s
19:08:50  13 actionable tasks: 4 executed, 9 up-to-date
19:08:51  
19:08:51  FAILURE: Build completed with 2 failures.
19:08:51  
19:08:51  1: Task failed with an exception.
19:08:51  -----------
19:08:51  * What went wrong:
19:08:51  Execution failed for task ':sonar'.
19:08:51  > Metaspace
19:08:51  
19:08:51  * Try:
19:08:51  > Run with --info or --debug option to get more log output.
19:08:51  > Run with --scan to get full insights.
19:08:51  
19:08:51  * Exception is:
19:08:51  org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonar'.
19:08:51  	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:145)
19:08:51  	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
19:08:51  	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:143)
19:08:51  	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131)
19:08:51  	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
19:08:51  	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
19:08:51  	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
19:08:51  	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
19:08:51  	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
19:08:51  	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
19:08:51  	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
19:08:51  	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
19:08:51  	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
19:08:51  	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
19:08:51  	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
19:08:51  	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
19:08:51  	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
19:08:51  	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
19:08:51  	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
19:08:51  	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
19:08:51  	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
19:08:51  	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
19:08:51  	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
19:08:51  	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402)
19:08:51  	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389)
19:08:51  	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382)
19:08:51  	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368)
19:08:51  	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
19:08:51  	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
19:08:51  	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
19:08:51  	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
19:08:51  	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
19:08:51  	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
19:08:51  	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
19:08:51  Caused by: java.lang.OutOfMemoryError: Metaspace
19:08:51  
19:08:51  ==============================================================================
19:08:51  
19:08:51  2: Task failed with an exception.
19:08:51  -----------
19:08:51  * What went wrong:
19:08:51  Metaspace
19:08:51  
19:08:51  * Try:
19:08:51  > Run with --info or --debug option to get more log output.
19:08:51  > Run with --scan to get full insights.
19:08:51  
19:08:51  * Exception is:
19:08:51  java.lang.OutOfMemoryError: Metaspace
19:08:51  
19:08:51  ==============================================================================
19:08:51  
19:08:51  * Get more help at https://help.gradle.org
19:08:51  
19:08:51  Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
19:08:51  
19:08:51  You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
19:08:51  
19:08:51  See https://docs.gradle.org/7.3/userguide/command_line_interface.html#sec:command_line_warnings
19:08:51  
19:08:51  BUILD FAILED in 34s
19:08:53  
19:08:53  FAILURE: Build failed with an exception.
19:08:53  
19:08:53  * What went wrong:
19:08:53  Could not receive a message from the daemon.
19:08:53  
19:08:53  * Try:
19:08:53  > Run with --info or --debug option to get more log output.
19:08:53  > Run with --scan to get full insights.
19:08:53  
19:08:53  * Exception is:
19:08:53  org.gradle.launcher.daemon.client.DaemonConnectionException: Could not receive a message from the daemon.
19:08:53  	at org.gradle.launcher.daemon.client.DaemonClientConnection.receive(DaemonClientConnection.java:83)
19:08:53  	at org.gradle.launcher.daemon.client.DaemonClientConnection.receive(DaemonClientConnection.java:35)
19:08:53  	at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:235)
19:08:53  	at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:204)
19:08:53  	at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:153)
19:08:53  	at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:99)
19:08:53  	at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:57)
19:08:53  	at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:210)
19:08:53  	at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:275)
19:08:53  	at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:247)
19:08:53  	at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:82)
19:08:53  	at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:30)
19:08:53  	at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:92)
19:08:53  	at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:38)
19:08:53  	at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:44)
19:08:53  	at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
19:08:53  	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
19:08:53  	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
19:08:53  	at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:240)
19:08:53  	at org.gradle.launcher.Main.doAction(Main.java:35)
19:08:53  	at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
19:08:53  	at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
19:08:53  	at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
19:08:53  	at org.gradle.launcher.GradleMain.main(GradleMain.java:31)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
19:08:53  	at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:35)
19:08:53  	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108)
19:08:53  	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)
19:08:53  Caused by: org.gradle.internal.remote.internal.RecoverableMessageIOException: Could not read message from '/127.0.0.1:39547'.
19:08:53  	at org.gradle.internal.remote.internal.inet.SocketConnection.receive(SocketConnection.java:88)
19:08:53  	at org.gradle.launcher.daemon.client.DaemonClientConnection.receive(DaemonClientConnection.java:77)
19:08:53  	... 34 more
19:08:53  Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.sonarqube.gradle.SonarTask_Decorated
19:08:53  	at java.base/java.io.ObjectInputStream.readObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.defaultReadFields(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readSerialData(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.defaultReadFields(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.defaultReadObject(Unknown Source)
19:08:53  	at java.base/java.lang.Throwable.readObject(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
19:08:53  	at java.base/java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readSerialData(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readObject(Unknown Source)
19:08:53  	at java.base/java.util.concurrent.CopyOnWriteArrayList.readObject(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
19:08:53  	at java.base/java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readSerialData(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.defaultReadFields(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.defaultReadObject(Unknown Source)
19:08:53  	at org.gradle.internal.exceptions.DefaultMultiCauseException.readObject(DefaultMultiCauseException.java:67)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
19:08:53  	at java.base/java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readSerialData(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectInputStream.readObject(Unknown Source)
19:08:53  	at org.gradle.internal.serialize.DefaultSerializer.read(DefaultSerializer.java:48)
19:08:53  	at org.gradle.launcher.daemon.protocol.DaemonMessageSerializer$SuccessSerializer.read(DaemonMessageSerializer.java:164)
19:08:53  	at org.gradle.launcher.daemon.protocol.DaemonMessageSerializer$SuccessSerializer.read(DaemonMessageSerializer.java:109)
19:08:53  	at org.gradle.internal.serialize.DefaultSerializerRegistry$TaggedTypeSerializer.read(DefaultSerializerRegistry.java:147)
19:08:53  	at org.gradle.internal.serialize.Serializers$StatefulSerializerAdapter$1.read(Serializers.java:36)
19:08:53  	at org.gradle.internal.remote.internal.inet.SocketConnection.receive(SocketConnection.java:81)
19:08:53  	... 35 more
19:08:53  Caused by: java.io.NotSerializableException: org.sonarqube.gradle.SonarTask_Decorated
19:08:53  	at java.base/java.io.ObjectOutputStream.writeObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeSerialData(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
19:08:53  	at java.base/java.lang.Throwable.writeObject(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
19:08:53  	at java.base/java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeSerialData(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeObject(Unknown Source)
19:08:53  	at java.base/java.util.concurrent.CopyOnWriteArrayList.writeObject(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
19:08:53  	at java.base/java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeSerialData(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
19:08:53  	at org.gradle.internal.exceptions.DefaultMultiCauseException.writeObject(DefaultMultiCauseException.java:73)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:08:53  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19:08:53  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
19:08:53  	at java.base/java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeSerialData(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeObject0(Unknown Source)
19:08:53  	at java.base/java.io.ObjectOutputStream.writeObject(Unknown Source)
19:08:53  	at org.gradle.internal.serialize.DefaultSerializer.write(DefaultSerializer.java:57)
19:08:53  	at org.gradle.launcher.daemon.protocol.DaemonMessageSerializer$SuccessSerializer.write(DaemonMessageSerializer.java:137)
19:08:53  	at org.gradle.launcher.daemon.protocol.DaemonMessageSerializer$SuccessSerializer.write(DaemonMessageSerializer.java:109)
19:08:53  	at org.gradle.internal.serialize.DefaultSerializerRegistry$TaggedTypeSerializer.write(DefaultSerializerRegistry.java:154)
19:08:53  	at org.gradle.internal.serialize.Serializers$StatefulSerializerAdapter$2.write(Serializers.java:46)
19:08:53  	at org.gradle.internal.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:122)
19:08:53  	at org.gradle.launcher.daemon.server.SynchronizedDispatchConnection.dispatchAndFlush(SynchronizedDispatchConnection.java:56)
19:08:53  	at org.gradle.launcher.daemon.server.DefaultDaemonConnection.completed(DefaultDaemonConnection.java:149)
19:08:53  	at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:41)
19:08:53  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
19:08:53  	at org.gradle.launcher.daemon.server.api.HandleReportStatus.execute(HandleReportStatus.java:33)
19:08:53  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
19:08:53  	at org.gradle.launcher.daemon.server.exec.HandleCancel.execute(HandleCancel.java:39)
19:08:53  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
19:08:53  	at org.gradle.launcher.daemon.server.api.HandleInvalidateVirtualFileSystem.execute(HandleInvalidateVirtualFileSystem.java:46)
19:08:53  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
19:08:53  	at org.gradle.launcher.daemon.server.api.HandleStop.execute(HandleStop.java:46)
19:08:53  	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
19:08:53  	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecuter.executeCommand(DaemonCommandExecuter.java:55)
19:08:53  	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:161)
19:08:53  	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:134)
19:08:53  	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:122)
19:08:53  	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
19:08:53  	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
19:08:53  	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
19:08:53  	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
19:08:53  	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
19:08:53  	at java.base/java.lang.Thread.run(Unknown Source)
19:08:53  
19:08:53  
19:08:53  * Get more help at https://help.gradle.org

I tried increasing the Sonar metaspace several times, as well as the size of the metaspace in the jenkins slave (just for testing purposes), without success.
The Metaspace in Kubernetes is by default defined at 100m.
So I guess giving it a max around 4G should be enough to detect the error, but that’s not the case.
In the values file of the Helm chart of SonarQube I added this snippet:

env:
  - name: SONAR_WEB_JAVAOPTS
    value: "-Xmx4G -Xms1G -XX:MaxMetaspaceSize=4G -XX:MetaspaceSize=1G"

Also monitoring for resources and request/limits in Kubernetes seems everything’s okay.

I’ve followed some of the tutorials like the one present when creating a new project in SonarQube, and my config is similar to this one:

plugins {
  id "org.sonarqube" version "3.5.0.2730"
}

sonar {
  properties {
    property "sonar.projectKey", "my-app"
    ... more properties/
  }
}

In the Jenkinsfile

node {
  stage('SCM') {
    checkout scm
  }
  stage('SonarQube Analysis') {
    withSonarQubeEnv() {
      sh "./gradlew sonar --stacktrace -x testCoverage"
    }
  }
}

I’m stuck for a week now. I have been trying many approaches and currently only downgrading SonarQube is the way to go. Is it a bug that I should report?

Hi @DrumSergio ,

Welcome to our community!

Which version of Gradle are you using? And on which SonarQube edition are you? And, asking a stupid question here: you did increase the memory of the k8s pod, right? Not only write “4G” in the SONAR_WEB_JAVAOPTS (which would simply max out the default 100m of the pod)?