Skip to content

"stream+x-jackson-smile" is not supported by default #10756

Closed

Description

@panterose

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

Activity

  1. added
    status: waiting-for-triage
    on Oct 24, 2017
  2. wilkinsona commented on Oct 24, 2017

    @wilkinsona
    Member

    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?

  3. added
    status: waiting-for-feedback
    on Oct 24, 2017
  4. panterose commented on Oct 26, 2017

    @panterose
    Author

    Here is a minimal project:
    smile.zip

  5. added
    status: feedback-provided
    and removed
    status: waiting-for-feedback
    on Oct 26, 2017
  6. self-assigned this
    on Oct 27, 2017
  7. wilkinsona commented on Oct 27, 2017

    @wilkinsona
    Member

    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.

  8. added
    status: invalid
    and removed
    status: feedback-provided
    status: waiting-for-triage
    on Oct 27, 2017
  9. bclozel commented on Dec 22, 2017

    @bclozel
    Member

    For reference: SPR-16151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: invalid

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions