Skip to content

Use fixed locale when deriving environment variable names from properties#11915

Open
TimurRakhmatullin86 wants to merge 1 commit into
testcontainers:mainfrom
TimurRakhmatullin86:fix/config-env-var-locale-uppercase
Open

Use fixed locale when deriving environment variable names from properties#11915
TimurRakhmatullin86 wants to merge 1 commit into
testcontainers:mainfrom
TimurRakhmatullin86:fix/config-env-var-locale-uppercase

Conversation

@TimurRakhmatullin86

Copy link
Copy Markdown

Describe the broken behaviour

TestcontainersConfiguration#getConfigurable maps a configuration property
name to the corresponding environment variable name by upper-casing it:

String envVarName = propertyName.replaceAll("\\.", "_").toUpperCase();

String#toUpperCase() uses the JVM default locale. Several property names
contain the letter i (docker.client.strategy, image.substitutor,
client.ping.timeout, testcontainers.reuse.enable, ...). Under a locale
with different case-mapping rules — most notably the Turkish locale, where
i upper-cases to the dotted capital İ (U+0130) — the derived name becomes
e.g. TESTCONTAINERS_İMAGE_SUBSTİTUTOR instead of
TESTCONTAINERS_IMAGE_SUBSTITUTOR. It no longer matches the ASCII environment
variable that is actually set in the process, so the variable is silently
ignored
and Testcontainers falls back to the property/default value.

This reproduces on any JVM whose default locale has non-ASCII case mapping for
i (e.g. started with -Duser.language=tr, or on a machine with a Turkish or
Azerbaijani system locale). The failure is silent — no error is logged, the
environment variable simply has no effect — which makes it easy to miss.

How the change fixes it

Derive the environment variable name with Locale.ROOT, so the case
conversion is independent of the JVM default locale.

The change is intentionally scoped to this single configuration entry point.
Other locale-less toUpperCase()/toLowerCase() call sites exist elsewhere in
the codebase, but they are left out to keep this fix atomic and easy to review.

Test

Added TestcontainersConfigurationTest#shouldReadEnvVarRegardlessOfDefaultLocale,
which sets the default locale to Turkish and verifies that an environment
variable is still resolved. It fails before the change and passes after it;
the default locale is restored in a finally block.

…ties

TestcontainersConfiguration derives the environment variable name for a
configuration property by upper-casing the property name with the default
locale. Under locales with different case-mapping rules (for example the
Turkish locale, where 'i' maps to the dotted capital 'İ'), the derived name
no longer matches the ASCII environment variable that is actually set, so
the environment variable is silently ignored.

Use Locale.ROOT for the case conversion so that resolution of configuration
from environment variables is independent of the JVM default locale.
@TimurRakhmatullin86 TimurRakhmatullin86 requested a review from a team as a code owner July 6, 2026 02:25
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.

1 participant