Skip to content

Incomplete debug message in ConfigurationClassBeanDefinitionReader#36410

Closed
cetf9h wants to merge 1 commit intospring-projects:mainfrom
cetf9h:main
Closed

Incomplete debug message in ConfigurationClassBeanDefinitionReader#36410
cetf9h wants to merge 1 commit intospring-projects:mainfrom
cetf9h:main

Conversation

@cetf9h
Copy link
Contributor

@cetf9h cetf9h commented Mar 3, 2026

I found some code to simplify when using IDEA to inspect the code, so I submit a PR here.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 3, 2026
@sbrannen sbrannen added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 3, 2026
@sbrannen

This comment was marked as outdated.

@sbrannen sbrannen closed this Mar 3, 2026
@bclozel bclozel self-assigned this Mar 3, 2026
@bclozel bclozel added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) and removed status: declined A suggestion or change that we don't feel we should currently apply labels Mar 3, 2026
@bclozel bclozel added this to the 7.0.6 milestone Mar 3, 2026
@bclozel
Copy link
Member

bclozel commented Mar 3, 2026

I think this PR is valid, the parentheses do have a meaning here and are actually fixing a bug. In Java, the method call . operator has a higher precedence than the string concatenation + operator. Here, the arguments are only applied to the last string, before concatenation - so arguments are in fact not replaced.

See the following:

System.out.println("First %s" + ", second %s" + ", third".formatted("1", "2"));
// prints 'First %s, second %s, third'

System.out.println(("First %s" + ", second %s" + ", third").formatted("1", "2"));
// prints 'First 1, second 2, third'

Reopening.

@bclozel bclozel reopened this Mar 3, 2026
@sbrannen

This comment was marked as outdated.

@cetf9h
Copy link
Contributor Author

cetf9h commented Mar 3, 2026

image @sbrannen

I did not use AI.
My test results are shown in the figure.
In the original str1 + str2.formatted(beanMethod, beanName), the str2.formatted(beanMethod, beanName) part is executed first, and then its result is concatenated with str1.

我没有使用AI
我的测试结果如图,原来的 str1 + str2.formatted(beanMethod, beanName),其中 str2.formatted(beanMethod, beanName) 会先执行,然后其结果与 str1 进行连接

@bclozel bclozel changed the title Fix format string argument count Fix debug message in ConfigurationClassBeanDefinitionReader Mar 3, 2026
@bclozel bclozel changed the title Fix debug message in ConfigurationClassBeanDefinitionReader Incomplete debug message in ConfigurationClassBeanDefinitionReader Mar 3, 2026
@bclozel bclozel closed this in 3c6f1b3 Mar 3, 2026
bclozel pushed a commit that referenced this pull request Mar 3, 2026
@github-actions github-actions bot added the status: backported An issue that has been backported to maintenance branches label Mar 3, 2026
@bclozel
Copy link
Member

bclozel commented Mar 3, 2026

Thanks @cetf9h this is now merged and backported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants