Skip to content

YAML in ConfigMaps is decoded with the platform default encoding instead of UTF-8 #1007

@edouardhue

Description

@edouardhue

Describe the bug

In Spring Cloud Kubernetes 2.1.1, the YAML document extracted from a ConfigMap is retrieved as a String, then encoded to bytes with getBytes() to be wrapped in a ByteArrayResource. getBytes() is called without an encoding, which default to the platform default encoding, which might not be UTF-8. This leads to encoding issues when the YAML document contains characters unsupported by the platform encoding. Also, per-spec, YAML documents are UTF encoded.

Here is the faulty line:

A workaround is to force the JVM encoding with -Dfile.encoding=UTF-8 but this might not always be suitable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions