apache / apache/shenyu

CachedBodyOutputMessage usage like this will cause memory leak ?

Open
#5,396 1 comment 0 reactions 0 assignees View on GitHub
type: question
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

### Question

` CachedBodyOutputMessage outputMessage = ResponseUtils.newCachedBodyOutputMessage(exchange);

return serverRequest.bodyToMono(String.class)
.switchIfEmpty(Mono.defer(() -> Mono.just("")))
.flatMap(convert)
.flatMap(body -> {
BodyInserter 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 ?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the shown CachedBodyOutputMessage flow through ResponseUtils.newCachedBodyOutputMessage, ResponseUtils.release, and the later filter's response.write call. Determine whether the cached body is released on that path, and document the observed lifecycle or a reproducible failure case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.