I want to add code that would simulate latency in my WebClient calls so I could ensure my timeouts/retries/etc are working correctly.
Since WebClient is reactive and uses a thread pool, it seems like Thread.sleep would block the thread in a way that WebClient wouldn't typically be blocked in real usage.
Is there a better way to simulate that latency?
public class LatencyInducingRequestInterceptor implements ClientHttpRequestInterceptor {
  public ClientHttpResponse intercept(
      HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
    ClientHttpResponse response = execution.execute(request, body);
    try {
      Thread.sleep(2000);
    } catch (InterruptedException e) {
      // do nothing
    }
    return response;
  }
}