spring-projects / spring-projects/spring-boot

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

Open
#43,919 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

There are different styles in the codebase, even in a single source file, is it possible and worthy to force same style by ArchUnit?

Nested/Collection/Map configuration property

  1. implicit initialized with null and expose getter and setter
  2. explicit initialized and expose getter and setter
  3. explicit initialized and mark the field as final (no setter)

I vote for option 2, and it is more common in the codebase.

Set/Map configuration property

  1. initialized with HashSet/HashMap
  2. initialized with LinkedHashSet/LinkedHashMap

I think option 2 is meaningless since the Binder will create ordered Set/Map.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the @ConfigurationProperties patterns described in the issue and how ArchUnit is used or could be used in the Spring Boot codebase. Compare the initialization and Set/Map styles, then determine whether the proposed conventions can be enforced consistently. Done means the style choice is explicit and the relevant code is consistently checked.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.