infinispan-spring-boot icon indicating copy to clipboard operation
infinispan-spring-boot copied to clipboard

InfinispanCacheMeterBinder throws NullPointerException when statistics-available="false"

Open asmirnou opened this issue 4 years ago • 1 comments

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:

  1. Clone this repo https://github.com/asmirnou/infinispan-spring-boot-npe
  2. Run ./gradlew bootRun
  3. 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">

asmirnou avatar Nov 27 '20 14:11 asmirnou

thank you @asmirnou ! I will open a jira

karesti avatar Dec 01 '20 13:12 karesti