FasterXML / FasterXML/jackson-dataformats-text
Add support for non-blocking ("async") YAML parsing
- Dominant language
- Java
- Stars
- 455
- Forks
- 164
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 2
Description
Jackson-core supports [non-blocking parsers](http://fasterxml.github.io/jackson-core/javadoc/2.10/com/fasterxml/jackson/core/JsonFactory.html#createNonBlockingByteArrayParser--) since [version 2.9](http://fasterxml.github.io/jackson-core/javadoc/2.9/com/fasterxml/jackson/core/JsonFactory.html#createNonBlockingByteArrayParser--), but YAML doesn't seem to have a non-blocking parser yet.
This is preventing us from parsing YAML request bodies directly in reactive web apps (Spring WebFlux).
These are the steps to reproduce this problem:
1. Create a YAML decoder:
```java
public class YamlDecoder extends AbstractJackson2Decoder {
public YamlDecoder() {
super(new YAMLMapper(), MediaType.valueOf("application/x-yaml"));
}
}
```
2. Add it as a custom decoder:
```java
@EnableWebFlux
public class AppConfiguration implements WebFluxConfigurer {
...
@Override
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
configurer.customCodecs().decoder(new YamlDecoder());
}
}
```
3. Add a REST controller with a mapping that consumes YAML:
```java
@RestController
public class FoobarController {
@PostMapping(value = "/foo", consumes = "application/x-yaml")
public void foo(@RequestBody MyCustomClass body) {
...
}
}
```
4. Send a YAML request. Then an `UnsupportedOperationException` will be [thrown from `JsonFactory`](https://github.com/FasterXML/jackson-core/blob/2.11/src/main/java/com/fasterxml/jackson/core/JsonFactory.java#L1122) with the message:
```
Non-blocking source not (yet?) supported for this format (YAML)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.