Skip to content

Changes in cache made within transaction must be visible for current transaction [SPR-12756] #17353

Closed
@spring-projects-issues

Description

@spring-projects-issues

Stas Volsky opened SPR-12756 and commented

As TransactionAwareCacheDecorator do actual cache operations on afterCommit phase there is incorrect behavior. Changes made in transaction are not visible to that transaction.

case:

  1. begin transaction
  2. call some method annotated with @Cacheable.
  3. call another method annotated with @CacheEvict
  4. call @Cacheable method one more time

expected behavior is that on step 4 cache will be empty inside current transaction and method will be executed one more time. but as changes will be applied only on transaction commit there are still cached results.

I suggest to make ThreadLocal map inside TransactionAwareCacheDecorator that will hold uncommited changes so it will be available to current transaction only. Or may be there is another solution.


1 votes, 5 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: bulk-closedAn outdated, unresolved issue that's closed in bulk as part of a cleaning process

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions