Skip to content

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

@mizosoft

Description

@mizosoft

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);

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions