Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractJackson2Decoder is not aware of jackson's non-blocking parser only supporting UTF-8 #24489

Closed
mizosoft opened this issue Feb 7, 2020 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@mizosoft
Copy link

mizosoft commented Feb 7, 2020

It appears that AbstractJackson2Decoder assumes that the non-blocking parser used with Jackson2Tokenizer auto-detects input's encoding. This appears to not be the case as the parser only works for UTF-8 and ASCII (see FasterXML/jackson-core#596). This causes it to fail with any non-UTF-8 compatible charset. For example, this code throws a DecodingException:

    DataBuffer jsonBuffer = new DefaultDataBufferFactory()
        .wrap("{\"Psst!\": \"I'm not UTF-8\"}".getBytes(StandardCharsets.UTF_16));
    Jackson2JsonDecoder decoder = new Jackson2JsonDecoder();
    Flux<Object> flux = decoder.decode(Flux.fromIterable(List.of(jsonBuffer)),
        ResolvableType.forType(new ParameterizedTypeReference<Map<String, String> >() {}),
        MediaType.parseMediaType("application/json; charset=utf-16"), Map.of());
    flux.subscribe(System.out::println);
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 7, 2020
@poutsma poutsma self-assigned this Feb 10, 2020
@poutsma poutsma added for: team-attention in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug and removed for: team-attention status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 17, 2020
@poutsma poutsma added this to the 5.2.4 milestone Feb 17, 2020
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.1.x labels Feb 17, 2020
poutsma added a commit that referenced this issue Feb 20, 2020
Jackson's asynchronous parser does not support any encoding except UTF-8
(or ASCII). This commit converts non-UTF-8/ASCII encoded JSON to UTF-8.

Closes gh-24489
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants