Skip to content

CachePublicMetrics does not support TransactionAwareCacheDecorator #8984

@altery

Description

@altery

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions