Skip to content

When I upgrade the version of spring-boot-starter-webflux from 3.2.2 to 3.2.6, there is a problem with retryWhen() and block() #33567

@YChen9511

Description

@YChen9511

Hello team,
I find that when I upgrade the version of spring-boot-starter-webflux from 3.2.2 to 3.2.6, there is a problem with retryWhen() and block().
Below is my code:

@RestController
public class TestController {
    private final Service service;

    public TestController(Service service) {
        this.service = service;
    }

    @GetMapping("/test")
    public Object testController(){
        return service.getDate("/non-existent-path", String.class).single().block();
    }
}
@org.springframework.stereotype.Service
@Slf4j
public class Service {
    WebClient client = WebClient.create("http://localhost:8080");

    public <T> Flux<T> getDate(String uri, Class<T> clazz){
        return client.get().uri(uri).retrieve().bodyToFlux(clazz)
                .retryWhen(Retry.backoff(3, Duration.ofMillis(2)).doBeforeRetry(
                        i->log.info(String.valueOf(i.totalRetriesInARow()), i.totalRetries())));
    }
}
<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
            <version>3.2.6</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.30</version>
        </dependency>

</dependencies>

Here is the specific phenomenon:
When I use webclient to call a non-existent uri and an 404 error occurs, block() and retryWhen() will asynchronously capture the error signal, causing my controller to return immediately. At the same time, there is an asynchronous thread executing the retry logic.

Before the retry logic is completed, block() captures the error signal.

What I expect is block() catches the error signal and then return after my retry logic is executed, just as version 3.2.2.
There's no such problem when i use version 3.2.2.

Looking forward to your reply. Thank u!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions