-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Problem
As was reported on Gitter, WebTestClient
uses the same thread to execute the controller's methods.
In case of Webflux, it means that Reactor's built-in blocking call detection (e.g. calling mono.block()
) or more advanced checks like BlockHound will not detect anything, since the thread is not non-blocking.
Since it creates a false positive feeling that the app does not have blocking calls, it would be better if WebTestClient
with Webflux would mimic the non-blocking nature of the Webflux calls and move the subscription to e.g. Schedulers.parallel()
Workaround
It is possible to customize the WebTestClient
and manually move the subscription to the parallel scheduler:
@Component
public class WebTestClientConfig implements WebTestClientBuilderCustomizer {
@Override
public void customize(WebTestClient.Builder builder) {
builder.filter((clientRequest, next) ->
next.exchange(clientRequest).subscribeOn(Schedulers.parallel())
);
}
}
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement