You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Non-ASCII characters are corrupted when importing properties content with the env: prefix #52647
SystemEnvironmentConfigDataResource turns the environment variable value into bytes with content.getBytes(StandardCharsets.UTF_8), but then calls loader.load(name, resource, this.encoding) with encoding == null unless the [encoding=...] hint is used. OriginTrackedPropertiesLoader then decodes with its default ISO-8859-1, so any non-ASCII character in a .properties-style variable is corrupted.
Since the environment variable is already a String, there is no file encoding involved, and the bytes Spring Boot produces itself are always UTF-8.
The same content imported as YAML (env:MY_CONF[.yaml]) is read correctly. Adding [encoding=utf-8] works around the problem, but users have no reason to expect they need it for an in-memory string.
Possible fix: in SystemEnvironmentConfigDataResource#load, default to the charset the content was encoded with:
I verified this end to end: I ran the packaged app as a separate process with the variable set and read the value over HTTP. With 4.1.2 the bytes are 47 72 c3 83 c2 bc .... With a locally built spring-boot jar including the change above, the result is Grüße (47 72 c3 bc c3 9f 65). The existing SystemEnvironmentConfigData* tests still pass. I'm happy to submit a PR with a test.
Activity
philwebb commentedon Nov 12, 2026
We have the same issue with 4.0.x but it's unfortunately too hard to fix there so we'll target this one to 4.1+
Use system environment charset when importing 'env:...' content