infinispan-spring-boot
infinispan-spring-boot copied to clipboard
InfinispanCacheMeterBinder throws NullPointerException when statistics-available="false"
Describe the bug
When cache is simple, statistics is not available and Infinispan embedded metrics are exposed using Micrometer, the following exception occurs:
Caused by: java.lang.NullPointerException: null
at org.infinispan.spring.starter.embedded.actuator.InfinispanCacheMeterBinder.size(InfinispanCacheMeterBinder.java:31) ~[infinispan-spring-boot-starter-embedded-2.3.4.Final.jar:2.3.4.Final]
at io.micrometer.core.instrument.binder.cache.CacheMeterBinder.bindTo(CacheMeterBinder.java:49) ~[micrometer-core-1.5.6.jar:1.5.6]
at org.springframework.boot.actuate.metrics.cache.CacheMetricsRegistrar.bindCacheToRegistry(CacheMetricsRegistrar.java:65) ~[spring-boot-actuator-2.3.5.RELEASE.jar:2.3.5.RELEASE]
To Reproduce
Steps to reproduce the behavior:
- Clone this repo https://github.com/asmirnou/infinispan-spring-boot-npe
- Run
./gradlew bootRun
- The exception above is thrown
Expected behavior
InfinispanCacheMeterBinder
handles the case when getStats()
returns null
if cache is of type SimpleCacheImpl
.
Additional context
The situation simulated in the demo project occurs in a real Spring Boot application when Hibernate 2nd level cache default configurations are used and Micrometer metrics are present.
<local-cache-configuration name="pending-puts" simple-cache="true" statistics="false" statistics-available="false">
thank you @asmirnou ! I will open a jira