Skip to content

Returning Mono.empty causes controller to halt #518

@bazusaladra

Description

@bazusaladra

The following code used to work on SpringBoot 2.0.2

    @GetMapping(path = "search")
    public Mono<String> search(@RequestParam(value = "query") String query) {
        if (Objects.isNull(query) || query.isEmpty()) {
            return Mono.empty();
        }
        return Mono.just("result: " + query);
    }

After upgrading to SpringBoot 2.1.0 calling

String actualEmptyResult = restTemplate.getForObject("/api/search?query=", String.class);

causes any subsequent requests to this endpoint to be stalled.
Please check out test org.springtest.EmptyMonoFailureTest#testMono in repository https://github.com/bazusaladra/spring-mono-test.
SpringBoot team advised this issue may be related to Reactor Netty: spring-projects/spring-boot#15214

Metadata

Metadata

Assignees

No one assigned

    Labels

    for/springframeworkThis belongs to the Spring Framework project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions