Skip to content

Use Locale.ROOT when lower-casing camel-case parts in ParsingUtils - #3563

Open
sharanggupta wants to merge 1 commit into
spring-projects:mainfrom
sharanggupta:parsing-utils-locale-root
Open

sharanggupta wants to merge 1 commit into
spring-projects:mainfrom
sharanggupta:parsing-utils-locale-root

Conversation

@sharanggupta

Copy link
Copy Markdown

ParsingUtils.split(source, toLower) lower-cases each camel-case part with String.toLowerCase(), which follows the JVM's default locale. Under a Turkish default locale (tr-TR, the default on any Turkish OS or user account) an uppercase I becomes a dotless ı (U+0131), so every consumer of splitCamelCaseToLower / reconcatenateCamelCase produces identifiers that do not exist:

// -Duser.language=tr -Duser.country=TR, spring-data-commons 4.1.1
ParsingUtils.reconcatenateCamelCase("InvoiceItem", "_");   // "ınvoice_ıtem"
ParsingUtils.reconcatenateCamelCase("invoiceId", "_");     // "invoice_ıd"
DefaultNamingStrategy.INSTANCE.getTableName(InvoiceItem.class); // "ınvoice_ıtem"  (Spring Data JDBC / R2DBC)

Affected callers: NamingStrategy.getTableName/getColumnName in Spring Data Relational (default SQL table and column names), SnakeCaseNamingStrategy in Spring Data Cassandra, CamelCaseSplittingFieldNamingStrategy (document field names) and XmlRepositoryConfigurationSource. The camel-case split itself uses \p{Lu} and is locale-independent; only the lower-casing is affected.

This uses Locale.ROOT, as AotContext, RepositoryBeanDefinitionBuilder and RepositoryConfigurationExtension already do in this module, and adds a unit test that switches the default locale to tr-TR around the conversion.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

ParsingUtils.split(source, toLower) lower-cases each camel-case part with
String.toLowerCase(), which follows the JVM's default locale. Under a
Turkish default locale an uppercase I becomes a dotless ı (U+0131), so
every consumer of splitCamelCaseToLower/reconcatenateCamelCase produces
identifiers that do not exist: Spring Data Relational's default table
and column names ("InvoiceItem" -> "ınvoice_ıtem", "invoiceId" ->
"invoice_ıd"), Cassandra's SnakeCaseNamingStrategy and
CamelCaseSplittingFieldNamingStrategy. The camel-case split itself uses
\p{Lu} and is locale-independent; only the lower-casing is affected.

Use Locale.ROOT, as AotContext, RepositoryBeanDefinitionBuilder and
RepositoryConfigurationExtension already do, and add a unit test that
switches the default locale to tr-TR around the conversion.

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 22, 2026
@christophstrobl

Copy link
Copy Markdown
Member

@sharanggupta thank you for reporting that issue!

@christophstrobl christophstrobl added the for: team-attention An issue we need to discuss as a team to make progress label Oct 23, 2026
@christophstrobl

Copy link
Copy Markdown
Member

From a quick glimpse across the codebase, ParsingUtils is not alone in calling lowercase without an argument.

@christophstrobl

Copy link
Copy Markdown
Member

Regarding the suggested code changes, I think we need a more differentiated approach.
We cannot simply change behaviour that has been this way for more than a decade.

@sharanggupta

Copy link
Copy Markdown
Author

Thanks, @christophstrobl. Understood that behaviour this old should not simply flip. I am happy to rework this along whatever direction the team settles on, for example one case-folding helper that the other call sites you spotted could share, or to close this in favour of a team-driven change.

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

Labels

for: team-attention An issue we need to discuss as a team to make progress status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants