Skip to content

Commit

Permalink
Mark attribute multipart parts for release (micronaut-projects#6511)
Browse files Browse the repository at this point in the history
Attribute parts were not released properly when combined with streaming another part. This patch adds the attribute part to the request so that the request handles cleanup. We can't release the data immediately, because the route method may still expect it as a ByteBuffer parameter.

There is no unit test for this, because this only fixes a bytebuf leak, which can't be tested in our current setup.

Fixes micronaut-projects#4837
  • Loading branch information
yawkat authored and dstepanov committed Nov 22, 2021
1 parent c6710d5 commit 1ce2da8
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -781,7 +781,14 @@ protected void doOnNext(Object message) {
if (!executed) {
String argumentName = argument.getName();
if (!routeMatch.isSatisfied(argumentName)) {
routeMatch = routeMatch.fulfill(Collections.singletonMap(argumentName, value.get()));
Object fulfillParamter = value.get();
routeMatch = routeMatch.fulfill(Collections.singletonMap(argumentName, fulfillParamter));
// we need to release the data here. However, if the route argument is a
// ByteBuffer, we need to retain the data until the route is executed. Adding
// the data to the request ensures it is cleaned up after the route completes.
if (!alwaysAddContent && fulfillParamter instanceof ByteBufHolder) {
request.addContent((ByteBufHolder) fulfillParamter);
}
}
if (isPublisher && chunkedProcessing) {
//accounting for the previous request
Expand Down

0 comments on commit 1ce2da8

Please sign in to comment.