You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Andrii Plotnikov (Jira)" <ji...@apache.org> on 2019/12/06 16:35:00 UTC

[jira] [Commented] (GROOVY-9090) StackOverflowError on Gradle compileGroovy

    [ https://issues.apache.org/jira/browse/GROOVY-9090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16989949#comment-16989949 ] 

Andrii Plotnikov commented on GROOVY-9090:
------------------------------------------

I found a work around for this issue.

I was needed to do 2 things: remove CompileStatic and TypeChecked annotations from the classes and increase xmx for groovy compiler. In my case I was needed to increase xmx from 768m to 1G. Maybe it is possible to give less memory but it requires experiments.
{code:java}
tasks.withType(GroovyCompile) {
    configure(groovyOptions.forkOptions) {
        memoryMaximumSize = '1G'
    }
}{code}
After removing annotations I started facing issues with GC for gradle builds. That's why I have increased xmx for Groovy compiler
{noformat}
15:48:48 Execution failed for task ':module-x:sub-module-y:compileTestGroovy'.
15:48:48 > GC overhead limit exceeded{noformat}
Also I want to describe 1 case which I found, in which the issue was happened.

The class is used for test proposes to do REST calls to the testing server. There are a lot of methods with the code like that in the class:
{code:java}
Response response = anonymous()
    .target('url')
    .request()
    .post(json(body))

return create(response, MyClass)
{code}
Those requests are written via `javax.ws.rs:javax.ws.rs-api:2.1.1` = implementation is jersey `org.glassfish.jersey.core:jersey-client:2.22.1`.

Only 1 strange thing which I spotted inside that class is that it contains a closure for `with` method on the object. Everything else was kind of the pure Java code. I was tried to improve that code to rewrite it to use `tap` and replace the closure with Map constructor. No of those improvements didn't help. When I remove CompileStatic on this class the issue was fixed.

Example of code to make it more visible
{code:java}
static MyClass2 createMyClass2() {
    new MyClass().with {
        email = 'email'
        name = 'name'
        login = name
        it
    }
}
{code}
Replaced with
{code:java}
static MyClass2 createMyClass2() {
    return new MyClass(
        email: 'email',
        name: 'name',
        login: 'name'
    )
}{code}
Also that class has a parent class which is written into the pure Java style (java object, the file with java extension) with the same type of methods = rest calls to the server.

I hope my detail description will help someone to cope with such type of issues or to find the root cause of the issue by developers.

> StackOverflowError on Gradle compileGroovy
> ------------------------------------------
>
>                 Key: GROOVY-9090
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9090
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.6
>         Environment: macOS
>            Reporter: Martin
>            Priority: Major
>
> h3. h3. Dependencies
> Java version: 1.8 or 11.  Both display same issue
> Gradle Version: 5.4
> Spring Boot 2.1.4.RELEASE
> h3. h3. Build Output
> {code:java}
> $ ./gradlew compileGroovy --stacktrace
> > Task :compileGroovy FAILED
> FAILURE: Build failed with an exception.
> * What went wrong:
> Execution failed for task ':compileGroovy'.
> > java.lang.StackOverflowError (no error message)
> * Try:
> Run with --info or --debug option to get more log output. Run with --scan to get full insights.
> * Exception is:
> org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileGroovy'.
> at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
> at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
> at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
> at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:141)
> at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
> at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
> at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
> at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
> at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
> at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
> at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
> at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
> at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
> at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
> at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
> at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
> at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
> at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
> at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
> at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
> at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
> at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
> at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
> at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
> at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
> at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
> at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
> at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
> at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
> at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
> at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
> at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
> at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
> at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
> at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
> at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
> at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
> at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
> at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
> Caused by: java.lang.StackOverflowError
> * Get more help at https://help.gradle.org
> BUILD FAILED in 5s
> 1 actionable task: 1 executed{code}
> h3. Notes
> Works fine with Groovy 2.4.16



--
This message was sent by Atlassian Jira
(v8.3.4#803005)