Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
243 views
in Technique[技术] by (71.8m points)

java - Memory leakage: connections are not disposed even after the use of releasebody()

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...