-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
AbstractCacheManager.getCache() breaks contract of CacheManager.getCache() #23193
Comments
It should only create a new cache if What is the concrete subclass of |
I think it's worth updating the documentation to reflect that in any case, since any custom implementation of |
@sbrannen, in my case the implementation is And regarding the documentation, I still find it unclear. It states:
But it is simply not true for |
The To disable that feature, you will need to set the
The updated documentation does not state that it returns Rather, it states that it returns |
Affects: Spring Boot version 2.1.3
Problem: According to the documentation,
CacheManager.getCache(String)
must returnHowever,
AbstractCacheManager
doesn't implement this contract. Instead, it always returns a not-null value disregards to what was requested. In fact, it creates a new cache every time an unknown cache is requested.It is misleading and error-prone. I relied on this functionality in my code and ended up with broken business logic.
More details.
Here is the documentation of
CacheManager.getCache(String)
:And here is the implementation of
AbstractCacheManager.getCache(String)
:Potential solutions: Please either update the documentation and make sure it is mentioned that the method could also create a cache or update the implementation, or, if I am missing something, make the documentation transparent.
The text was updated successfully, but these errors were encountered: