Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

ConsulConfigProperties#getAclToken() remains null although spring.cloud.consul.token is available in the Environment

未关闭
#996 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
java, spring-boot
领域
backend, cloud

调研方向

从 ConsulConfigProperties 和 issue 中显示的 aclToken 字段开始,然后跟踪属性来自 ConfigData Vault 源时其 @Value 表达式是如何解析的。将该路径与 Environment.getProperty 和常规的 @Value 注入进行比较;完成的标准是确定 null 值是否符合预期,或通过有针对性的覆盖率测试复现回归问题。

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

描述

waiting-for-triage

Description

I'm investigating the behavior of ConsulConfigProperties#getAclToken() in Spring Cloud Consul and I'm not sure whether this is an intended behavior or a bug.

In my application, spring.cloud.consul.token is successfully loaded from Spring Cloud Vault through ConfigData.

The property is available in the Environment, and a regular @Value("${spring.cloud.consul.token}") injection works correctly.

However, ConsulConfigProperties#getAclToken() always returns null.

Versions

  • Spring Boot: 3.5.14
  • Spring Cloud Release Train: 2025.0.1
  • spring-cloud-consul-config: 4.3.1

Configuration

spring:
  config:
    import:
      - vault://
      - consul://

  cloud:
    consul:
      config:
        enabled: true

The Consul ACL token is stored in Vault under:

spring.cloud.consul.token

Observations

The following values are logged during application startup:

Environment.getProperty("spring.cloud.consul.token")
=> 08****35 (masked intentionally)

ConsulConfigProperties#getAclToken()
=> null

The property source owning the property is:

dev-secret/consul-configs

Additional verification

To make sure this was not a configuration issue, I performed the following checks:

  • Environment.getProperty("spring.cloud.consul.token") returns the expected value.
  • A regular Spring bean using
@Value("${spring.cloud.consul.token}")
private String token;

receives the correct value.

  • ConsulConfigProperties itself is properly bound:

    • enabled
    • defaultContext
    • prefixes

    all contain the expected values.

  • Using reflection confirms that the internal aclToken field is still null.

Field field = ConsulConfigProperties.class.getDeclaredField("aclToken");
field.setAccessible(true);

System.out.println(field.get(consulConfigProperties));
// null

The field is annotated with:

@Value("${consul.token:${CONSUL_TOKEN:${spring.cloud.consul.token:${SPRING_CLOUD_CONSUL_TOKEN:}}}}")
private String aclToken;

and the annotation is present at runtime.

Question

Is this expected?

Should ConsulConfigProperties#getAclToken() be populated from spring.cloud.consul.token, or is the aclToken field intentionally left unset when using ConfigData (Vault)?

If it is expected to be populated, this appears to be a regression because:

  • the property exists in the Environment,
  • @Value works on regular Spring beans,
  • only the aclToken field inside ConsulConfigProperties remains null.
主要语言
Java
星标
821
派生
540
平均合并
12 小时 56 分钟
30 天内合并 PR
15

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

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

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

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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