-
Bug
-
Resolution: Done
-
Critical
-
7.2.0.GA
With a rest resource method returning a POJO and annotated with @Produces(Mediatype.APPLICATION_JSON), the returned response response is incorrectly encoded (uses US_ASCII instead of utf-8).
The workaround is to add a parameter to the mediatype: @Produces("application/json;charset=utf-8").
There is 2 issues concerning compliance with the RFC7159 json spec:
- As per the json spec, charset parameters should be discarded:
Note: No "charset" parameter is defined for this registration. Adding one really has no effect on compliant recipients.
- As per the json spec, json is utf-8 encoded:
JSON text SHALL be encoded in UTF-8, UTF-16, or UTF-32. The default encoding is UTF-8, and JSON texts that are encoded in UTF-8 are interoperable in the sense that they will be read successfully by the maximum number of implementations
Checking this issue with Wireshark and this end-point:
@GET @Produces("application/json") @Path("a") public CustomObject a() throws Exception { return new CustomObject().setA("öü"); }
- default encoding (UTF8) + default json provider (JSON-B)
- correct: UTF8 - "öü" - 22 c3 b6 c3 bc 22
- default encoding (UTF8) + old json provider (Jackson)
- correct: UTF8 - "öü" - 22 c3 b6 c3 bc 22
- us-ascii + default json provider (JSON-B)
- wrong: us-ascii - "??" - 22 3f 3f 22
- 3f is literally '?' according to the first google response
- us-ascii + old json provider (Jackson)
- correct: UTF8 - "öü" - 22 c3 b6 c3 bc 22
Upstream jira: https://issues.jboss.org/browse/RESTEASY-2171
- clones
-
RESTEASY-2171 JsonBindingProvider use incorrect charset encoding
- Resolved
- is incorporated by
-
JBEAP-16914 [GSS](7.2.z) Upgrade RESTEasy from 3.6.1.SP5 to 3.6.1.SP6
- Closed
- is related to
-
JBEAP-16540 (CD16) JsonBindingProvider use incorrect charset encoding
- Closed