borinquenkid opened a new pull request, #16034:
URL: https://github.com/apache/grails-core/pull/16034

   ## Summary
   `WhereQueryClosureCaptureSpec` has two flaky feature methods (~2% flaky per
   apache/grails-core#16030, 0 hard failures) verifying that closures generated 
by the
   `where {}` query transform only capture the variables they actually 
reference.
   
   ## Root cause
   `AstPropertyResolveUtils.cachedClassProperties` is a static, non-thread-safe 
`HashMap`
   used by the `where`-transform's variable-scope recompute path
   (`DetachedCriteriaTransformer`). It was already keyed by 
`ClassNode.getName()`
   (qualified name), not a bare simple name as first suspected — but 
`ClassNode.equals()`/
   `hashCode()` also compare by name, and this spec's own test deliberately 
compiles
   identical source **twice** into two separate `GroovyClassLoader`s, producing 
two
   distinct `ClassNode` instances that are `equals()`-identical and therefore 
collide as
   the same cache entry. This is reachable by any two classes sharing a name 
across
   separate compilations, not just this test — a prior partial fix (08bd0bfbeb) 
only
   renamed this spec's fixtures to reduce collisions with sibling specs, 
without fixing
   the cache itself.
   
   ## Fix
   - Switched `cachedClassProperties` to a synchronized 
`IdentityHashMap<ClassNode, ...>`
     — keys compared by `==`, so two distinct `ClassNode`s can never collide 
regardless of
     shared naming.
   - Fixed a related concurrency bug in the same method: a new cache entry was 
previously
     published into the shared map *before* its population loop finished, 
letting a
     concurrent reader observe a partially-populated entry. Population now 
completes into
     a local map first, then publishes atomically.
   
   ## Testing
   - New `AstPropertyResolveUtilsSpec.groovy` (public-API only): includes a 
test that
     constructs two distinct `ClassNode`s sharing the exact same name and 
asserts each
     resolves independently — a direct, deterministic reproduction of the 
collision
     mechanism, not a rerun-and-hope test.
   - `:grails-datamapping-core:test` (full module): BUILD SUCCESSFUL, no 
failures,
     including both previously-flaky feature methods.
   - CodeNarc/Checkstyle: clean.
   
   Related: apache/grails-core#16030


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to