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

Controller method with empty Flowable response sends incorrect body #82

Closed
gjong opened this issue Oct 8, 2020 · 0 comments · Fixed by #83
Closed

Controller method with empty Flowable response sends incorrect body #82

gjong opened this issue Oct 8, 2020 · 0 comments · Fixed by #83

Comments

@gjong
Copy link

gjong commented Oct 8, 2020

Thanks for reporting an issue, please review the task list below before submitting the
issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.

NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (https://stackoverflow.com/tags/micronaut) or Gitter (https://gitter.im/micronautfw/). DO NOT use the issue tracker to ask questions.

Task List

  • [ x] Steps to reproduce provided
  • [ x] Stacktrace (if present) provided
  • [ x] Example that reproduces the problem uploaded to Github
  • [ x] Full description of the issue provided (see below)

Steps to Reproduce

  1. Create a basic controller with a method sending a Flowable
  2. In the body of the method return a Flowable.empty(), or alternatively create a flowable and just send the onComplete()
  3. Call the method using CURL / Postman
  4. Inspect the body of the http response
package com.example;

import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.reactivex.Flowable;

@Controller("/hello-world")
public class HelloController {

    @Get
    public Flowable<String> helloWorld() {
        return Flowable.empty();
    }

}
  :> curl --header 'Accept: application/json' --request GET http://localhost:8080/hello-world

Expected Behaviour

I would expect a JSON response body indicating an empty response, thus containing the following body:

[]

Actual Behaviour

Instead of receiving an empty JSON array the operation returns the following malformed JSON:

]

Environment Information

  • Operating System: Windows
  • Micronaut Version: 2.1.0
  • JDK Version: 14

Example Application

https://github.com/gjong/micronaut-flowable-failure

@jameskleeh jameskleeh transferred this issue from micronaut-projects/micronaut-core Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant