Skip to content

CachePublicMetrics does not support TransactionAwareCacheDecorator #8984

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

Closed
altery opened this issue Apr 24, 2017 · 3 comments
Closed

CachePublicMetrics does not support TransactionAwareCacheDecorator #8984

altery opened this issue Apr 24, 2017 · 3 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@altery
Copy link

altery commented Apr 24, 2017

CacheManagers that extend from AbstractTransactionSupportingCacheManager, for example JCacheCacheManager, support transaction awareness by wrapping the Cache in a TransactionAwareCacheDecorator. If enabled, the cache statistics provided by the Spring Boot Actuator project cease to work.

The problem is, that CachePublicMetrics#getCacheStatistics search for a suitable CacheStatisticsProvider by comparing the runtime type of the Cache against the generic type of all registered CacheStatisticsProviders. This, of course, doesn't work if the Cache is wrapped in a completely different type.

As a workaround, I added a new AbstractJmxCacheStatisticsProvider<TransactionAwareCacheDecorator> that contains the same implementation as JCacheCacheStatisticsProvider (because we use JCacheCaches).

We use Spring Boot 1.4.1, but I quickly checked the latest version on Github, and there doesn't seem to be any changes in this area.

I guess CachePublicMetrics#getCacheStatistics should first unwrap TransactionAwareCacheDecorator before trying to lookup a stats provider.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 24, 2017
@snicoll
Copy link
Member

snicoll commented Apr 25, 2017

@altery it's not that easy unfortunately. TransactionAwareCacheDecorator does not provide access to the Cache it wraps. I've created an improvement in the framework to expose that.

Thanks for the report!

@snicoll snicoll added type: bug A general bug priority: normal and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 25, 2017
@altery
Copy link
Author

altery commented Apr 25, 2017

Yes, without using reflection it would require a change in spring-context-support first. Maybe raise a issue there?

@altery
Copy link
Author

altery commented Apr 25, 2017

Thanks!

@snicoll snicoll self-assigned this Apr 25, 2017
@snicoll snicoll added this to the 1.4.7 milestone Apr 25, 2017
snicoll added a commit that referenced this issue May 2, 2017
CachePublicMetrics wasn't explicitly tested and was still using field
injection. This commit improves the situation in preparation of the fix
for gh-8984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants