Skip to content

Possible regression between 1.3 and 1.4 regarding UTF-8 handling? (Spring 5.1.12) #317

Closed
@eranation

Description

@eranation
  • Framework version: 1.4
  • Implementations: Spring

Scenario

I upgrade a project from 1.3.2 to 1.4. I have some responses that return UTF-8 encoded JSON strings, e.g.

/**
 * test utf (for unit testing only)
 */
@GetMapping(path = "/utf-test", produces = "application/json; charset=utf-8")
Map<String, ?> testUTF() {
  Map<String, Object> ret = new HashMap<>();
  ret.put("message", "שלום");
  return ret;
}

p.s. Adding the following didn't seem to change much

LambdaContainerHandler.getContainerConfig().setDefaultContentCharset("UTF-8");

As well as this (to application.properties)

spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true

Expected behavior

response should return as {"message": "שלום"}
(this is what I get in 1.3.2)

Actual behavior

response returns as: {"message":"ש���"}
(this is what I get when upgrading to 1.4)

Steps to reproduce

I tried this with both java 1.8 and java 11 using these core dependencies

<spring.version>5.1.12.RELEASE</spring.version>
<jackson.version>2.10.1</jackson.version>

with nothing changed, it works in 1.3.2, and broke in 1.4, not sure if I'm doing something wrong...

Full log output

N / A

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