KafkaStreamsBinderMetrics throws ClassCastException
See original GitHub issueon the start up of application, when metrics is binded to MeterRegistry by org.springframework.cloud.stream.binder.kafka.streamsKafkaStreamsBinderMetrics.
I am getting following error:
`
java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Double (java.lang.Long and java.lang.Double are in module java.base of loader ‘bootstrap’) at org.springframework.cloud.stream.binder.kafka.streams.KafkaStreamsBinderMetrics$1.lambda$toDoubleFunction$0(KafkaStreamsBinderMetrics.java:92) ~[spring-cloud-stream-binder-kafka-streams-3.0.0.RELEASE.jar!/:3.0.0.RELEASE] at io.micrometer.core.instrument.internal.DefaultGauge.value(DefaultGauge.java:54) ~[micrometer-core-1.3.1.jar!/:1.3.1] at io.micrometer.prometheus.PrometheusMeterRegistry.lambda$newGauge$3(PrometheusMeterRegistry.java:245) ~[micrometer-registry-prometheus-1.3.1.jar!/:1.3.1] at io.micrometer.prometheus.MicrometerCollector.collect(MicrometerCollector.java:69) at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:190) ~[simpleclient-0.7.0.jar!/:na] at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:223) at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:144) at io.prometheus.client.exporter.common.TextFormat.write004(TextFormat.java:22) ~[simpleclient_common-0.7.0.jar!/:na] at org.springframework.boot.actuate.metrics.export.prometheus.PrometheusScrapeEndpoint.scrape(PrometheusScrapeEndpoint.java:50) ~[spring-boot-actuator-2.2.1.RELEASE.jar!/:2.2.1.RELEASE] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java) ~[na:na] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:279) ~[spring-core-5.2.1.RELEASE.jar!/:5.2.1.RELEASE] at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.j.
`
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Spring cloud Kafka streams Deserialiation issue wtih Caused by
I'm trying to use the spring cloud Kafka streams binder to consume Avro messages from the topic but not able to fix this...
Read more >spring-cloud/spring-cloud-stream - Gitter
cloud.stream.bindings.applicationMetrics.destination=metrics property, I am faced with an Exception: java.lang.IllegalStateException: The binder 'kstream' ...
Read more >Spring for Apache Kafka
The metrics and partitionsFor methods delegate to the same methods ... If your application uses the Kafka binder in spring-cloud-stream and ...
Read more >spring-cloud - Bountysource
with Kafka Streams Binder a java.lang.ClassCastException is thrown. The changes made for #997 in KafkaStreamsBinderSupportAutoConfiguration are putting both ...
Read more >Upgrade Guide and API Changes - Apache Kafka
Brokers must be on version 0.10.1 or higher to run a Kafka Streams application version ... The 2.4.0 release contains newly added and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/blob/master/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsBinderMetrics.java there is a cast to Double which causes the exception:
Programmatically it is probably not a good idea to check for Number and cast to Double instead as mentioned in https://stackoverflow.com/questions/32757565/java-lang-long-cannot-be-cast-to-java-lang-double. Instead I would suggest:
The error occurs with the following dependencies:
org.springframework.boot:spring-boot-starter-webflux:2.2.2.RELEASE org.springframework.kafka:spring-kafka:2.3.4.RELEASE org.springframework.cloud:spring-cloud-stream:3.0.1.RELEASE org.springframework.cloud:spring-cloud-stream-binder-kafka:3.0.1.RELEASE