Skip to content

CachedBodyOutputMessage usage like this will cause memory leak ? #5396

@ihenjoy

Description

@ihenjoy

Question

` CachedBodyOutputMessage outputMessage = ResponseUtils.newCachedBodyOutputMessage(exchange);

    return serverRequest.bodyToMono(String.class)
            .switchIfEmpty(Mono.defer(() -> Mono.just("")))
            .flatMap(convert)
            .flatMap(body -> {
                BodyInserter<String, ReactiveHttpOutputMessage> bodyInserter = BodyInserters.fromValue(body);
                return bodyInserter.insert(outputMessage, new BodyInserterContext());
            }).then(Mono.defer(() -> {
                ServerHttpRequestDecorator decorator = new RequestDecorator(exchange, outputMessage);
                return Mono.just(exchange.mutate().request(decorator).build());
            })).onErrorResume(throwable -> ResponseUtils.release(outputMessage, throwable));`

if the filter after this , e.g check some parameter ,call response.write ,the cache body can be release ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions