Skip to content

Conversation

@Chrimle
Copy link
Contributor

@Chrimle Chrimle commented Nov 12, 2025

Fixes #22313 and fixes #22269, by doing a partial revert of #21871, and replacing all introduced import java.util.Locale; with Fully-Qualified uses i.e. java.util.Locale. The reason is that the import of java.util.Locale will clash/conflict with any other class named Locale in the current package. The intention is to again allow custom classes, pojos/enums, to be named Locale and to be used in other generated classes, as it was pre-v7.16.0.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Signed-off-by: Chrimle <[email protected]>
@Chrimle
Copy link
Contributor Author

Chrimle commented Nov 12, 2025

@wing328 really not sure why it is failing. The error indicates that the samples are not updated, but they are 🤔

Edit: nevermind, the /bin structure is unlike the /resources structure, so had so also re-run "spring*" 🤦

@Chrimle Chrimle marked this pull request as ready for review November 12, 2025 23:04
@Picazsoo
Copy link
Contributor

Hello @Chrimle, I am not a maintainer, but this change looks sensible to me. I really like that you changed it everywhere even though it might theoretically not cause an issue everywhere, since I expect others can be expected to follow the style going forward when submitting a PR.

As is, I am afraid that someone might unknowingly reintroduce this bug with good intentions. Maybe at least a unit test with api spec testing for the absence of import java.util.Locale and presence of the FQN would make sense? But I understand testing it everywhere would be pretty excessive. But anything is better than nothing in my opinion.

@Chrimle
Copy link
Contributor Author

Chrimle commented Nov 13, 2025

@Picazsoo Correction; Initially ALL imports were replaced by inline:ing. However, on second thought, it was deemed a bit risky, since it would affect non-pojo classes. Hence, it was reverted, and only the mustache-files modified in #21871 , were partially reverted (removing the imports) and the usage of Locales are now fully qualified.

This means, classes pre-7.16.0 that were importing Locale have NOT been modified. Only the mustache files, and the resulting generated pojos, modified in 7.16.0.

Edit: Should the PR title be reworded to better reflect this? Suggestions welcomed

@Chrimle Chrimle changed the title [Java] Use Fully Qualified Name for All java.util.Locale Usages [Java] Use Fully Qualified Name for java.util.Locale in Generated Classes Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][JAVA] Unused Locale Imports [BUG] java.util.Locale is mixed with custom component if named "Locale"

2 participants