Skip to content

[Bug]: SolaceMeterConfiguration causes NullPointerException later on #497

Description

@sebastiankirsch

Bug Description

The SolaceMeterConfiguration is configured with @ConditionalOnClass(MeterRegistry.class), yet the SolaceMessageMeterBinder requires a MeterRegistry (bean) to be available. If that isn't present, consuming messages fails (see below).

java.lang.NullPointerException: Cannot invoke "io.micrometer.core.instrument.MeterRegistry.summary(io.micrometer.core.instrument.Meter$Id, io.micrometer.core.instrument.distribution.DistributionStatisticConfig, double)" because "registry" is null
	at io.micrometer.core.instrument.DistributionSummary$Builder.register(DistributionSummary.java:415)
	at io.micrometer.core.instrument.DistributionSummary$Builder.register(DistributionSummary.java:411)
	at com.solace.spring.cloud.stream.binder.meter.SolaceMessageMeterBinder.registerSizeMeter(SolaceMessageMeterBinder.java:39)
	at com.solace.spring.cloud.stream.binder.meter.SolaceMessageMeterBinder.recordMessage(SolaceMessageMeterBinder.java:26)
	at com.solace.spring.cloud.stream.binder.meter.SolaceMeterAccessor.recordMessage(SolaceMeterAccessor.java:18)
	at com.solace.spring.cloud.stream.binder.inbound.InboundXMLMessageListener.receive(InboundXMLMessageListener.java:136)
	at com.solace.spring.cloud.stream.binder.inbound.InboundXMLMessageListener.run(InboundXMLMessageListener.java:93)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Expected Behavior

SolaceMeterConfiguration should be annotated with @ConditionalOnBean(MeterRegistry.class) instead; then SolaceMeterAccessor/SolaceMessageMeterBinder either won't be defined as beans; or if a MeterRegistry exists, the aforementioned NPE won't occur.

Steps to Reproduce

In a vanilla Spring Boot project, add io.micrometer:micrometer-core as depdendency.

Solace Broker version

No response

Solace API

No response

Solace API version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions