apache / apache/grails-core

`@CacheEvict` & CompileStatic errors for key closures

Open
#15,191 2 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-cache relates-to: groovy
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Issue description

The following code worked in Grails 6 on a class annotated with `@CompileStatic`

@CacheEvict(value = "apiTokens", key = { token })
void deleteByToken(String token) {

In Grails 7, this fails with:

[Static type checking] - The variable [token] is undeclared.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Grails 7 CompileStatic error with the @CacheEvict example in the issue, then compare the same case against Grails 6. Trace how the key closure is handled for @CacheEvict and verify that the example compiles while still using token for eviction.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.