Even after processing the body and releasing it my connections are disposed. I cant use retrieve() as i need to check status code.
WebClient webClient = WebClient.create("http://localhost:8066");
public Mono<City> getCityById(Integer id){
return webClient.get()
.uri("/cities/" + id)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.exchange()
.flatMap(clientResponse -> {
if (clientResponse.statusCode().value() == HttpStatus.BAD_REQUEST.value()) {
return clientResponse.bodyToMono(BadRequestException.class)
.flatMap(errorDetails -> Mono.error(new BadRequestException(errorDetails.getMessage())));
} else if (clientResponse.statusCode().is4xxClientError()) {
return clientResponse.bodyToMono(NotFoundException.class)
.flatMap(errorDetails -> Mono.error(new NotFoundException(errorDetails.getMessage())));
}
Mono<City> val = clientResponse.bodyToMono(City.class);
clientResponse.releaseBody();
return val;
}
);
question from:
https://stackoverflow.com/questions/66054183/memory-leakage-connections-are-not-disposed-even-after-the-use-of-releasebody 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…