The GitHub Actions job "Groovy Snapshot Canary Build" on 
grails-core.git/fix/16294-16295-non-public-bean-marshalling has succeeded.
Run started by GitHub user sbglasius (triggered by sbglasius).

Head commit for run:
2e08c1fc152b6f1a88974647e9848c3e8c2bcc1e / Søren Berg Glasius 
<[email protected]>
Widen a private method copy instead of the cached descriptor

`ReflectionUtils.makeAccessible` flips the flag on the `Method` instance that
Spring's `CachedIntrospectionResults` hands back, and that instance is shared:
every later `BeanUtils.getPropertyDescriptors` call for the class returns the
same already-invokable object, for the lifetime of the cache.

Re-resolve the method from its declaring class instead. `getDeclaredMethod`
returns a fresh copy per call, so `setAccessible` touches nothing but our own
copy. The extra lookup only happens when access is actually denied — the common
case, a read method resolved to a public interface method, is already invokable
and pays nothing.

The field loops need no equivalent change: `getDeclaredFields` already returns a
fresh copy on every call, so widening one never escapes.

Both specs gain a test that reads the cached descriptor back after marshalling
and fails if the flag was flipped.

Raised in review of #16296.

Report URL: https://github.com/apache/grails-core/actions/runs/34202640141

With regards,
GitHub Actions via GitBox

Reply via email to