Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-blocking @Cacheable method does not support condition with #result #31626

Closed
yangwenliang123 opened this issue Nov 20, 2023 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@yangwenliang123
Copy link

yangwenliang123 commented Nov 20, 2023

@Cacheable(cacheNames = "user", unless = "#result.id != null", key = "#id")
public Mono<User> index(@PathVariable Long id) {
        return Mono.just(MAP.get(id));
 }
public class User {
    private Long id;
    private String name;
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 20, 2023
@snicoll snicoll changed the title spring6.1 reactor cache not support #result operate Non blocking @Cacheable method does not support condition with #result Nov 20, 2023
@snicoll snicoll added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 20, 2023
@snicoll snicoll added this to the 6.1.x milestone Nov 20, 2023
@snicoll
Copy link
Member

snicoll commented Nov 20, 2023

Thanks for the report.

The condition is applied upfront so that result refers to the actual Mono<User> rather than User as you would expect. We'll have to figure out how to delay the condition evaluation so that the actual result object is available.

@sbrannen sbrannen changed the title Non blocking @Cacheable method does not support condition with #result Non-blocking @Cacheable method does not support condition with #result Nov 21, 2023
@jhoeller jhoeller self-assigned this Nov 21, 2023
@jhoeller jhoeller modified the milestones: 6.1.x, 6.1.1 Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants