Skip to content

Use LinkedHashMap and LinkedHashSet in configuration properties#50367

Open
GollapudiSrikanth wants to merge 4 commits into
spring-projects:mainfrom
GollapudiSrikanth:srikanthgollapudi-archunit-config-properties-style
Open

Use LinkedHashMap and LinkedHashSet in configuration properties#50367
GollapudiSrikanth wants to merge 4 commits into
spring-projects:mainfrom
GollapudiSrikanth:srikanthgollapudi-archunit-config-properties-style

Conversation

@GollapudiSrikanth
Copy link
Copy Markdown
Contributor

@GollapudiSrikanth GollapudiSrikanth commented May 7, 2026

This PR updates @ConfigurationProperties classes to use LinkedHashMap and LinkedHashSet consistently instead of HashMap and HashSet.

This aligns with the preferred convention discussed in #43919 and provides consistent ordering behavior across collection and map configuration properties.

While working on this, I also noticed a number of cases involving final nested/collection/map properties that would require broader changes to align with the preferred option 2 style (initialized field with getter/setter). To keep this PR focused and easier to review, those changes have been left for potential follow-up work.

Screenshot 2026-05-07 145717 image

Closes #43919

Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
… Arch rule

Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 7, 2026
GollapudiSrikanth and others added 2 commits May 7, 2026 17:38
Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
Copy link
Copy Markdown
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, I've left some comments for your consideration.

@Override
public boolean test(CodeUnitCallTarget target) {
String ownerName = target.getOwner().getName();
return ("java.util.HashMap".equals(ownerName) || "java.util.HashSet".equals(ownerName))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explicitly check for the presence of those two and would miss all other cases. It'd be better if the rule checks that field of type Map or Set, if initialized, uses LinkedHashMap or LinkedHashSet respectively. I also don't think we need to link those two together. We could have a "is property of type X initialized, make sure it is Y. With that we can have three rules for List, Set and Map that call the same logic with different arguments.

*
* @author Stephane Nicoll
* @author Madhura Bhave
* @author Venkata Naga Sai Srikanth Gollapudi
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the author tag for every configurationproperties you've touched that only changes the type. This isn't considered as a significant change.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use consistent style for Nested/Collection/Map properties in @ConfigurationProperties

3 participants