Scrivio Interview library
ScenarioAdvanced7 min read · updated 12 November 2026

A blocking Spring MVC service uses WebClient with block() everywhere because RestClient did not exist when it was written. Should it be changed, and how would you decide?

WebClient with block() works in a Spring MVC service, but it pulls in Reactor and Reactor Netty and adds a second threading model and a second set of HTTP configuration to a service that is blocking everywhere else. RestClient, available since Spring Framework 6.1, gives the same fluent style for blocking code without the reactive stack. I would not rewrite it in one go: I would change clients when the code is touched or when the reactive dependency causes real trouble, keep WebClient where calls are genuinely composed concurrently (or move those to RestClient on virtual threads), and follow the organisation's HTTP client standard.

Why this question is asked

Many Spring MVC services written between 2018 and 2023 use WebClient with block() because RestTemplate was in maintenance mode and RestClient did not exist yet. Now that RestClient is here, teams ask whether that code is technical debt worth paying off. Interviewers ask this because it is a judgement question: there is no bug, the code works, and the senior answer weighs real costs against the cost and risk of change. In this answer, we will recap what each client is, look at what block() really costs in a blocking service, see how the migration looks in code, and then walk through how we would decide, call site by call site.

1A Quick Recap of the Three Spring Clients

Spring has three main clients for outgoing HTTP calls. RestTemplate is the original blocking client with a method per HTTP verb; it is in maintenance mode, which means it gets fixes but no new features, and later Spring versions plan to deprecate it (check your version). WebClient arrived with Spring WebFlux in Spring 5. It is reactive: each call returns a Mono or Flux, and by default it runs on Reactor Netty, a non-blocking network library with its own event loop threads. RestClient arrived in Spring Framework 6.1 with Spring Boot 3.2. It has the same fluent builder style as WebClient, but each call simply returns the value, on the calling thread.

block() is the method that turns a Mono back into a plain value. It subscribes and then parks the calling thread until the value arrives. In a Spring MVC controller the calling thread is a servlet container thread, for example a Tomcat worker, so blocking it is allowed and works.

The three clients side by side
ClientStyleThreadsStatus
RestTemplateone method per verbcaller blocksmaintenance mode
WebClientfluent, returns Mono/FluxNetty event loop, non-blockingactive, for reactive code
RestClientfluent, returns valuescaller blocksactive since Spring 6.1
RestClient is the blocking client with WebClient's style.

2What block() Costs in a Blocking Service

The code works, so the costs are indirect, and it helps to name them. The first is the dependency itself. spring-webflux, Reactor Core and Reactor Netty come into the classpath, with their own release cycles, so every Spring Boot upgrade has more moving parts and more transitive versions to align. The second is a second threading model. Each blocked request now involves two threads: the Tomcat thread waiting in block(), and a reactor-http-nio thread doing the actual network work. Thread dumps show both, and stack traces of failures come from the Netty thread, which makes debugging harder for a team that does not otherwise use Reactor.

The third is duplicated configuration. Timeouts, connection pools, TLS, proxies and metrics are configured one way for Reactor Netty and another way for anything else the service uses. The fourth is a real trap: if someone ever calls block() on a Netty event loop thread, for example inside a WebClient filter, Reactor throws an IllegalStateException saying that block() is not supported in that thread. Nothing is broken today, but the codebase carries a mechanism the team does not need.

Java
// Typical code today
Customer c = webClient.get().uri("/customers/{id}", id)
.retrieve()
.bodyToMono(Customer.class)
.block(Duration.ofSeconds(3)); // Tomcat thread parks; a reactor-http-nio thread does the I/O
// The same call with RestClient
Customer c2 = restClient.get().uri("/customers/{id}", id)
.retrieve()
.body(Customer.class); // one thread, no Reactor on the stack

Notice how close the two versions are. The builder, uri(), retrieve() and onStatus() look the same, so most call sites migrate in a few minutes. The timeout moves from block(Duration) to the request factory configuration, where it arguably belonged all along.

3When to Make the Change

Rewriting every client at once is risky and rarely pays for itself, so we look for moments when the cost of change is already low or the benefit is already real. The cheapest moment is when the code is touched anyway: a new endpoint on that dependency, a bug fix, or a change of API version. We migrate that client in the same pull request and test it with the change.

The other trigger is when the reactive stack causes real problems: a Boot upgrade blocked by a Reactor Netty incompatibility, a production issue that was hard to diagnose because of the extra threads, or a security fix in Netty we would not need at all. At that point a planned migration of the remaining clients is justified, and once the last WebClient is gone we can remove spring-boot-starter-webflux from the build.

Step throughDeciding for each WebClient call site
  1. Is the code being changed anyway?
    YesMigrate it to RestClient in the same changeNoNext question
  2. Does the reactive stack cause real trouble?upgrades, debugging, extra threads
    YesPlan migration of all clientsNoNext question
  3. Are calls composed concurrently?zip, parallel fan-out
    YesKeep WebClient, or RestClient on virtual threadsNoLeave it until touched
  4. Check the organisation's client standardthe standard can tip the decision

4 steps in order. Play them, or step through them one at a time.

4Where WebClient Still Earns Its Place

Some services use WebClient for more than a blocking call. They fan out to several dependencies with Mono.zip and block once at the end, or they stream a large Flux. For those call sites, a plain RestClient rewrite would make the calls sequential and slower. We have two good options. We can keep WebClient there, where its concurrency is actually used. Or, on Java 21 or later, we can run each RestClient call on its own virtual thread, a lightweight thread managed by the JVM that is cheap to block, and keep the code blocking and simple.

Java
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
Future<Price> price = executor.submit(() -> pricing.get().uri("/price/{id}", id).retrieve().body(Price.class));
Future<Stock> stock = executor.submit(() -> inventory.get().uri("/stock/{id}", id).retrieve().body(Stock.class));
return new ProductView(price.get(), stock.get()); // latency is the slower call, not the sum
}

Notice that this gives the same overlap as Mono.zip without Reactor. With spring.threads.virtual.enabled=true, Spring Boot 3.2 and later also run the request handling itself on virtual threads, so blocking a thread is cheap everywhere in the service. Java 25 also offers structured concurrency for this pattern, still as a preview feature, so check your version before relying on it.

5Aligning With the Organisation's Standard

The last input is not technical. If the platform team ships a starter that configures RestClient with the company's timeouts, tracing and authentication, every WebClient left in the service is a client that misses those defaults and must be configured by hand. In that case the migration is part of staying on the paved road. If instead the standard is WebClient because most services are reactive, a blocking service can reasonably keep it. Either way, one client per service is the goal, because two HTTP stacks mean two sets of pools, timeouts and metrics to get right.

6Follow-up questions

Is calling block() in a Spring MVC controller wrong?

No. It is supported and works, because the servlet thread is allowed to block. It is wrong only on a reactive event loop thread, where Reactor throws an IllegalStateException to protect the loop. In MVC the issue is cost and complexity, not correctness.

Can RestClient reuse the existing RestTemplate configuration?

Yes. RestClient.create(restTemplate) or RestClient.builder(restTemplate) builds a RestClient that reuses the template's request factory, interceptors and message converters. That makes a gradual move from RestTemplate easy. For WebClient there is no such bridge, so we configure the RestClient request factory with the same timeouts and pool settings.

Would you migrate if the team plans to move the service to WebFlux later?

Then I would wait, because the plan changes the answer: a reactive service should use WebClient everywhere. But I would ask how real the plan is. Many teams that once planned a WebFlux move now get the scalability they wanted from virtual threads while keeping blocking code.

7Conclusion

In this answer, we saw that WebClient with block() is correct in a blocking Spring MVC service but brings Reactor, Reactor Netty, a second threading model and a second set of HTTP settings into code that does not need them. RestClient gives the same fluent style with plain blocking calls, and migrating a call site is usually a small change. We decided not to rewrite everything at once, but to migrate when code is touched or when the reactive stack causes trouble, to keep WebClient or use virtual threads where calls are really composed concurrently, and to let the organisation's client standard settle the default.

What to say in the interviewAbout 80 seconds aloud

Open with

My short answer is: yes, eventually, but not as a big-bang rewrite. WebClient with block() works fine in Spring MVC, because Tomcat threads are allowed to block. The cost is that the service carries spring-webflux, Reactor and Reactor Netty just to make blocking calls, every request uses two threads, one waiting in block and one Netty thread doing the I/O, and timeouts, pools and metrics are configured differently from the rest of the service.

Then, if they want more

Since Spring 6.1, RestClient gives the same fluent API for blocking code, and a call like retrieve().bodyToMono(X.class).block() becomes retrieve().body(X.class). So I would migrate a client when we are touching that code anyway, and I would plan a full migration if the reactive stack is actually hurting us, for example blocking an upgrade or making incidents harder to debug.

The exception is call sites that really use reactive composition, like Mono.zip across three services. There I would keep WebClient, or move to RestClient running each call on a virtual thread, which gives the same overlap with plain code.

And I would check the platform standard: if the company starter configures RestClient with our timeouts and tracing, staying on WebClient means missing those defaults.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 3.2, Spring Framework 6, Java 21, Java 25
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A blocking Spring MVC service uses WebClient with block() everywhere because RestClient...": https://scrivio-interview-library.netlify.app/spring-boot/http-clients/acf393e15c/