Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intercepting Groovy dynamic calls stops working in subsequent builds reusing a running daemon #26053

Closed
h0tk3y opened this issue Aug 9, 2023 · 0 comments · Fixed by #26069
Closed
Assignees
Labels
a:bug in:configuration-cache Configuration Caching
Milestone

Comments

@h0tk3y
Copy link
Member

h0tk3y commented Aug 9, 2023

Current Behavior

Intercepting calls that are dynamically dispatched through Closures in Groovy build scripts works as expected in a cold daemon, but if the daemon is reused for subsequent builds, those builds do not have their dynamically dispatched calls intercepted properly.

For example, this call should always be tracked as a configuration input:

file("1.txt").with {
    println(isFile())
}

And it is in the first build, so running it will include the file system entry for 1.txt in the snapshot.
However, cleaning the configuration cache with rm -rf .gradle/configuration-cache and running the build again in the same daemon process will no longer track the isFile() call as a configuration input.

Expected Behavior

Subsequent builds in a running daemon should all intercept the Groovy calls uniformly.

Context (optional)

This is a bug in a new feature #24949.
It is most likely caused by the commit 1b36ab6.

Something in the Groovy runtime integration resets the instrumentation of the call sites for dynamic calls, and those fail to register themselves for call site matching in the intercepting meta class code.

Steps to Reproduce

Create an empty Gradle project, put the following in the build.gradle Groovy script:

file("1.txt").with {
    println(isFile())
}

Enable configuration caching in the gradle.properties:

org.gradle.configuration-cache=true

Use a Gradle Nightly distribution.
Run the build once:

gradlew help

Then clean the cache:

rm -rf .gradle/configuration-cache

And run the build again:

gradlew help

The second build will not produce a configuration report for 1.txt input, and the configuration cache entry will not be invalidated after changes to that entry (e.g. if 1.txt is created / removed).

Gradle version

8.4

Build scan URL (optional)

No response

Your Environment (optional)

No response

@h0tk3y h0tk3y self-assigned this Aug 9, 2023
@h0tk3y h0tk3y added the in:configuration-cache Configuration Caching label Aug 9, 2023
@h0tk3y h0tk3y added this to the 8.4 RC1 milestone Aug 9, 2023
bot-gradle added a commit that referenced this issue Aug 11, 2023
…epted in Groovy

The default Groovy implementation that decorated call sites would delegate to replaces the call site array entries, thus removing the intercepting call sites from the code path.

Fix this by writing the decorated call site references back to the call site array.

<!--- The issue this PR addresses -->
Fixes #26053

Co-authored-by: Sergey Igushkin <sigushkin@gradle.com>
@ov7a ov7a removed the to-triage label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug in:configuration-cache Configuration Caching
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants