You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"stream+x-jackson-smile" is not supported by default #10756
I can see the encoder and its test support this media-type, but when I try it on a sample project, it doesn't work. I want Smile (or CBOR) because our service sends lots of matrices and JSON is really inefficient compare to binary serialisation for numerical data.
Simplest reproducer:
@Test
public void binaryContent() throws Exception {
WebTestClient.bindToController(new MatrixController()).build()
.get().uri("/matrix")
.header("Accept", "application/stream+x-jackson-smile")
.exchange()
.expectStatus().isOk()
.returnResult(Matrix.class)
.getResponseBody()
.toIterable()
.forEach(m -> System.out.println(m));
}
@RestController
static class MatrixController {
@GetMapping(value = "/matrix", produces = {"application/stream+x-jackson-smile"})
Flux<Matrix> getMatrix() {
return Flux.range(0,1000)
.subscribeOn(Schedulers.single())
.map(i -> new Matrix(100,1000))
;
}
}
public static class Matrix {
private double[] array;
public Matrix() {}
public Matrix(int rows, int columns) {
this.array = new double[rows * columns];
}
public double[] getArray() {
return array;
}
public void setArray(double[] array) {
this.array = array;
}
}
Thanks for the code snippets, but they don't really give us enough information to diagnose the issue. Can you please provide a small, complete sample (something that we can unzip or clone and run) that reproduces the problem?
Thanks. Your test shows that this isn't a Spring Boot problem as SmileStreamTest doesn't use any of Spring Boot. It also doesn't have a dependency on jackson-dataformat-smile, however adding that dependency does not fix the problem. The problem appears to be that Jackson2SmileEncoder does not, by default, include stream+x-jackson-smile in the media types that it supports. If my analysis is correct, this will need to be corrected in Spring Framework.
Activity
wilkinsona commentedon Oct 24, 2017
Thanks for the code snippets, but they don't really give us enough information to diagnose the issue. Can you please provide a small, complete sample (something that we can unzip or clone and run) that reproduces the problem?
panterose commentedon Oct 26, 2017
Here is a minimal project:
smile.zip
wilkinsona commentedon Oct 27, 2017
Thanks. Your test shows that this isn't a Spring Boot problem as
SmileStreamTestdoesn't use any of Spring Boot. It also doesn't have a dependency onjackson-dataformat-smile, however adding that dependency does not fix the problem. The problem appears to be thatJackson2SmileEncoderdoes not, by default, includestream+x-jackson-smilein the media types that it supports. If my analysis is correct, this will need to be corrected in Spring Framework.bclozel commentedon Dec 22, 2017
For reference: SPR-16151