Affects: 6.1.1


We use @Cacheable on a few methods that have parameters of collection type and have a custom KeyGenerator implementation. In this key generator implementation we take into account each element of the input collections when creating the cache key.

After upgrading from Spring Boot 3.1.5 to 3.2.0 we noticed that CacheAspectSupport has changed its behaviour such that, in case of a miss, cache key generation is called after the @Cacheable method is invoked which means that the cache key might have changed if the collection elements were changed.

Previous versions were calculating the cache key for put before invoking the @Cacheable method, thus making sure the method parameters were not changed by the invocation.

Comment From: jhoeller

This seems to be caused by #31626 - we need to figure out a way to address both requirements without a regression there.

Comment From: jhoeller

Actually, the earlier change #22769 seems to be the root cause here, #31626 just a follow-up effect.