Kafka binder health-check consumer failures return DOWN without logging the exception

未关闭
#3,329 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Sanskar121543 已经在做这个了。

开始于 2026年11月5日。

  • #3331 来自 @Sanskar121543 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
java, kafka, spring-boot

调研方向

Start with AbstractKafkaBinderHealthIndicator.buildTopicsHealth() and safelyBuildTopicsHealth() in the Kafka binder core; the issue identifies both as paths that convert failures into health results without logging. Read the existing logging conventions for health indicator failures, then check that the returned health status remains DOWN and the underlying exception is logged without repeated probe failures flooding logs.

由索引模型根据 Issue 内容生成。

描述

Describe the issue

The Kafka binder can report DOWN because its health-check metadata consumer cannot be constructed, without logging the failure or its underlying cause. Meanwhile, application startup and the actual listener containers can succeed.

The health endpoint exposes only:

org.apache.kafka.common.KafkaException: Failed to construct kafka consumer

In the case we investigated, the underlying exception was:

java.lang.IllegalStateException: No delegate deserializer configured

This report is about missing error logging, not about accepting an incomplete deserializer configuration. Returning DOWN is appropriate, but the diagnostic cause should also be available in the application logs.

To Reproduce

The following is a reduced configuration illustrating the triggering setup: use ErrorHandlingDeserializer at binder scope and configure its value delegate only at binding scope.

  1. Start a Spring Boot application with Actuator, the web starter, the Spring Cloud Stream Kafka binder, and a reachable plaintext Kafka broker.

  2. Register a simple function:

    @Bean
    public Consumer<String> consume() {
        return value -> {};
    }
    
  3. Configure the binder and binding:

    management:
      endpoint:
        health:
          show-details: always
    
    spring:
      cloud:
        function:
          definition: consume
        stream:
          bindings:
            consume-in-0:
              destination: health-repro
              group: health-repro
              consumer:
                useNativeDecoding: true
          kafka:
            binder:
              brokers: localhost:9092
              consumer-properties:
                key.deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
                value.deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
                spring.deserializer.key.delegate.class: org.apache.kafka.common.serialization.StringDeserializer
            bindings:
              consume-in-0:
                consumer:
                  configuration:
                    spring.deserializer.value.delegate.class: org.apache.kafka.common.serialization.StringDeserializer
    
  4. Let the application start, then call GET /actuator/health.

  5. Observe that binder health is DOWN with Failed to construct kafka consumer, despite the listener container running. No corresponding health-check exception or nested cause is logged at WARN/ERROR.

The failure was reproduced in a multi-binder application and an HTTP integration test. The reduced single-binder example above is provided to illustrate the configuration pattern; it has not been run as a separate sample project.

Version of the framework

  • Spring Boot: 4.1.2
  • Spring Cloud release train: 2025.1.4
  • Spring Cloud Stream: 5.0.4
  • Spring Cloud Stream Kafka binder and Kafka binder core: 5.0.4
  • Spring for Apache Kafka (spring-kafka): 4.1.2
  • Apache Kafka clients: 4.2.2
  • Java: Eclipse Temurin 25.0.5

The Spring Boot, Spring Cloud, and Java settings were checked against the application build configuration. The packaged application JAR confirms the resolved Spring Boot, Spring Cloud Stream, Spring Kafka, and Kafka client versions. The failing HTTP integration test ran on Java 25.0.5. The exception-to-health-result handling was also checked in the released v5.0.4 source and on the main branch.

Expected behavior

When metadata consumer construction fails, log an ERROR identifying the Kafka binder health check and include the exception and full cause chain. If WARN is the project's convention for health-indicator failures, that would still be substantially more actionable than the current silent conversion.

The health endpoint should continue returning DOWN; startup need not fail solely because of a lazily created health-check consumer. Logging is expected when the health check actually encounters the failure, not necessarily during startup.

Please consider logging on the initial failure/state transition or otherwise deduplicating/rate-limiting repeated failures, so regular health probes do not flood logs with identical stack traces. There is no need to log configuration maps or credentials.

Additional context

The relevant code paths appear to be:

Because the exception is handled inside the indicator, the exception-logging path in the superclass is not reached. Health details retain the outer exception message rather than the useful nested deserializer error.

Supplying spring.deserializer.value.delegate.class at binder scope resolves this particular configuration failure, while bindings can still override the delegate as needed. However, that workaround does not address the missing diagnostics for this or other health-check failures.

I searched existing open issues for the exact error, missing delegates, the health indicator class, and health-check logging. Related but apparently different reports include spring-cloud/spring-cloud-stream#2958 (binary compatibility), spring-cloud/spring-cloud-stream#3042 (custom multi-binder indicators), and spring-cloud/spring-cloud-stream#3138 (Kafka Streams/DNS connectivity).

主要语言
Java
星标
1.1k
派生
653
平均合并
2 天 15 小时
30 天内合并 PR
8

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

spring-cloud/spring-cloud-stream 的其他 Issue

查看 spring-cloud/spring-cloud-stream 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。