I've created a WebClient to make a get request, and to specifically handle the 404 error I'm using the onStatus method as shown in the snippet below.
client.get()
.uri(someUrl)
.headers(someHeaders)
.retrieve()
.onStatus(status -> status.equals(HttpStatus.NOT_FOUND), r -> Mono.empty())
.bodyToMono(MyJsonResponse.class)
When I get a 404 in the response, my expectation is that it should return an empty mono, however, it calls subsequent body to mono as well and tries to parse the response, which, ideally it should not do. Any suggestions ?