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

Find a way to test a custom CacheInterceptor without using bean overriding #32530

Closed
snicoll opened this issue Mar 26, 2024 · 3 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: superseded An issue that has been superseded by another type: task A general task

Comments

@snicoll
Copy link
Member

snicoll commented Mar 26, 2024

In our efforts to get rid of bean overriding in the core framework, I am trying to migrate tests that use bean overriding.

JCacheCustomInterceptorTests is one of those, it exposes a JCacheInterceptor bean that should replace the infrastructure one that @EnableCaching produces. Now I've done the full exercise, I came to the conclusion that the test does not longer reproduce a valid use case (i.e. if a user tries to customize the infratructure, it will face the same problem).

Things I've tried:

  • Remove @EnableCaching and then import the individual components with an override for the one I want to customize: the infrastructure relies on @EnableCaching to be present and fail hard if it's not present.
  • I've removed that locally and now that's AutoProxyRegistrar that doesn't do anything (silently) as it can't find an @Enable-like annotation that provides the mode and proxyTargetClass attributes.
  • Reverting all of that and using a BeanPostProcessor to replace the interceptor bean. It's extra hard as the BPP needs to be configured before the caching infrastructure is registered.

I've managed to make it work by calling addBeanPostProcessor before registering the configuration class that enables caching.

It would be interesting to see how far we want to go with this. If we test this, then it must be possible for a user to have a valid configuration arrangement that does a similar thing.

@snicoll snicoll added type: task A general task in: core Issues in core modules (aop, beans, core, context, expression) labels Mar 26, 2024
@snicoll snicoll added this to the 6.2.x milestone Mar 26, 2024
@snicoll snicoll self-assigned this Mar 26, 2024
@snicoll
Copy link
Member Author

snicoll commented Apr 2, 2024

I actually implemented something in #31288. Anything that's more involved would require spring-test anyway and I am sure we'll collect such feedback down the road.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2024
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Apr 2, 2024
@snicoll snicoll removed this from the 6.2.x milestone Apr 2, 2024
@douxiaofeng99
Copy link

Does the task delayed? In my work, i need intercept the put and evict action to send redis message.

@snicoll
Copy link
Member Author

snicoll commented Jul 21, 2024

You’re asking this on the wrong channel. Please ask usage questions on Stackoverlow. This was mostly internal.

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) status: superseded An issue that has been superseded by another type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants