ConfigurationPropertiesRebinder doesn't rebind properties for a bean which was created during bootstrap phase

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
java, spring-boot
领域
backend

调研方向

从 spring-cloud-context/src/main/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinder.java 和复现测试 SpringCloudContextBugApplicationTests.shouldNotFailToUpdateApplicationPropertiesBean 开始。比较 spring-cloud-commons 3.1.4 和 3.1.5 之间的 rebind 行为,然后运行所引用的测试。完成的标准是 bootstrap 创建的 @ConfigurationProperties bean 能够接收到获取的 Spring Cloud 值,同时不破坏现有的 rebinding 行为。

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

描述

waiting-for-triage
Bug description

Version of spring-cloud-commons: 3.1.5 (in lower versions of spring-cloud-commons this bug doesn't occur)
Version of spring-boot: 2.7.9 (irrelevant)

When a bean using @ConfigurationProperties is created during bootstrap phase with values taken from bootstrap.yaml file, then the values of this bean's fields are not updated with properties fetched using spring-cloud.

Sample

I've created a repository which reproduces this bug: https://github.com/pitagoras3/spring-cloud-context-bug.

In this project, you can find a test SpringCloudContextBugApplicationTests.shouldNotFailToUpdateApplicationPropertiesBean which fails, when springCloudCommons version is >= 3.1.5.

Where is the problem?

After some debugging I've found out that rebind method in ConfigurationPropertiesRebinder had changed between versions 3.1.4 and 3.1.5. In my opinion the bug which I have described might be a side-effect of this specific change. In 3.1.5 version of spring-cloud-context my IncorrectProperties bean used in test is never destroyed and initialized again (as it was in version 3.1.4).

主要语言
Java
星标
751
派生
767
平均合并
1 天 1 小时
30 天内合并 PR
17

环境准备

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

从这里开始

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

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

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

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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