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
TransactionAwareCacheDecorator renders CacheErrorHandler useless #28554
Comments
When you say |
@sbrannen Ah yes, I meant |
@sbrannen Is there any update from your side? Anything I could do to support you with this? |
Any update on this? |
Maybe @rstoyanchev can explain why this has been removed from the Triage Queue without further comment? 🤔 |
We deleted the triage queue milestone in favor of a different internal process. Note that this issue is still assigned the “waiting-for-triage” label. So its status has not changed. |
Affects: All Versions since 3.2?
When configuring a custom cache error handler via
CachingConfigurer::errorHandler
and having transaction-aware caching enabled (for example, viaRedisCacheManager.RedisCacheManagerBuilder::transactionAware
, which decorates withTransactionAwareCacheDecorator
), the cache error handler is never called when the put fails inTransactionSynchronization::afterCommit
once the transaction was committed. In particular, this prevents users to suppress runtime exceptions from the cache backend by using theLoggingCacheErrorHandler
, such as connection problems or command timeouts from Redis.To illustrate the problem, I've created a simple demo project using Redis as a cache backend (which cannot connect as there's no Redis running on
localhost:6379
)The test where I did not enable transaction-awareness does not throw any exception, whereas the test with transaction-awareness does, rather unexpectedly, as I've installed a
LoggingCacheErrorHandler
.Note that I've configured a very dummy transaction handling to make the bug appear.
A workaround for the bug would be to not enable transaction-awareness via
RedisCacheManager.RedisCacheManagerBuilder::transactionAware
, but to instrument the cache manually. I did this with AOP on any cache instance by decorating theCacheManager::getCache
with a BeanPostProcessor, but this is quite ugly:Let me know if you need further information to reproduce the bug.
I've also just tried a fix, but I don't know how to get the error handler (which should be kind of a singleton from
CachingConfigurer
) into theAbstractTransactionSupportingCacheManager
. Any hints would be appreciated and I'd create a PR if this attempt goes into the right direction.The text was updated successfully, but these errors were encountered: